From 3203f9426e497d2de0b8dad29788efdf08232a8c Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Mon, 26 Oct 2020 20:53:33 +0800 Subject: [PATCH] feat: better experience with correct focus --- src/components/FileExplorer.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/FileExplorer.tsx b/src/components/FileExplorer.tsx index 5a56763..5ce60d7 100644 --- a/src/components/FileExplorer.tsx +++ b/src/components/FileExplorer.tsx @@ -175,13 +175,13 @@ function ListView({ const listRef = React.useRef(null) const { focusedNode, nodes } = visibleNodes React.useEffect(() => { - if (listRef.current && focusedNode?.path) { + if (listRef.current && focusedNode) { const index = nodes.findIndex(node => node.path === focusedNode.path) if (index !== -1) { listRef.current.scrollToItem(index, 'smart') } } - }, [focusedNode?.path]) + }) const goToCurrentItem = React.useCallback(() => { const targetPath = platform.getCurrentPath(metaData.branchName)