diff --git a/frontend/src/components/dirent-detail/detail-container.js b/frontend/src/components/dirent-detail/detail-container.js index 91ec125d9a..0e8dcb0c75 100644 --- a/frontend/src/components/dirent-detail/detail-container.js +++ b/frontend/src/components/dirent-detail/detail-container.js @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useMemo } from 'react'; import PropTypes from 'prop-types'; import LibDetail from './lib-details'; import DirentDetail from './dirent-details'; @@ -8,9 +8,10 @@ import { MetadataContext } from '../../metadata'; import { PRIVATE_FILE_TYPE } from '../../constants'; const DetailContainer = React.memo(({ repoID, path, dirent, currentRepoInfo, repoTags, fileTags, onClose, onFileTagChanged }) => { + const isView = useMemo(() => path.startsWith('/' + PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES), [path]); useEffect(() => { - if (path.startsWith('/' + PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES)) return; + if (isView) return; // init context const context = new MetadataContext(); @@ -22,12 +23,11 @@ const DetailContainer = React.memo(({ repoID, path, dirent, currentRepoInfo, rep delete window['sfMetadataContext']; } }; - }, [repoID, currentRepoInfo, path]); + }, [repoID, currentRepoInfo, isView]); - if (path.startsWith('/' + PRIVATE_FILE_TYPE.FILE_EXTENDED_PROPERTIES)) { + if (isView) { const viewId = path.split('/').pop(); if (!dirent) return (); - path = dirent.path; } if (path === '/' && !dirent) { @@ -41,7 +41,7 @@ const DetailContainer = React.memo(({ repoID, path, dirent, currentRepoInfo, rep return ( { const { column } = this.props; if (column.type === CellType.DATE && !isEscapeKeydown) return null; - this.onClickOutside(isEscapeKeydown); + !this.isClosed && this.onClickOutside(isEscapeKeydown); }; onClickOutside = (isEscapeKeydown) => { + this.isClosed = true; this.commit(); this.props.onCommitCancel(); !isEscapeKeydown && window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.SELECT_NONE); diff --git a/frontend/src/metadata/components/metadata-details/location/index.js b/frontend/src/metadata/components/metadata-details/location/index.js index 5e7eb5ad4f..60f458b493 100644 --- a/frontend/src/metadata/components/metadata-details/location/index.js +++ b/frontend/src/metadata/components/metadata-details/location/index.js @@ -48,6 +48,9 @@ class Location extends React.Component { this.googleMarker = null; } this.map = null; + this.setState = (state, callback) => { + return; + }; } initMap = (position) => {