diff --git a/src/components/FileExplorer/index.tsx b/src/components/FileExplorer/index.tsx index 67009017..86bbf5bd 100644 --- a/src/components/FileExplorer/index.tsx +++ b/src/components/FileExplorer/index.tsx @@ -5,7 +5,7 @@ import { SearchBar } from 'components/SearchBar' import { useConfigs } from 'containers/ConfigsContext' import { PortalContext } from 'containers/PortalContext' import { RepoContext } from 'containers/RepoContext' -import { platform } from 'platforms' +import { useInspector } from 'containers/StateInspector' import * as React from 'react' import { usePrevious, useUpdateEffect } from 'react-use' import { cx } from 'utils/cx' @@ -171,13 +171,21 @@ function LoadedFileExplorer({ const renderLabelText = useRenderLabelText(searchKey) const goToCurrentItem = React.useCallback(() => { - const targetPath = platform.getCurrentPath(metaData.branchName) + const targetPath = getCurrentPath() if (targetPath) expandTo(targetPath) - }, [metaData.branchName, expandTo]) + }, [getCurrentPath, expandTo]) useOnLocationChange(goToCurrentItem) useAfterRedirect(goToCurrentItem) + const [currentPath, setCurrentPath] = React.useState(() => getCurrentPath()) + useAfterRedirect( + React.useCallback(() => { + setCurrentPath(getCurrentPath()) + }, [getCurrentPath]), + ) + useInspector('CurrentPath', currentPath) + const ref = React.useRef(null) useFocusOnPendingTarget( 'files',