From 396af20fa44b0e73a6aebce03f08a679471c775f Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Wed, 28 Oct 2020 00:07:52 +0800 Subject: [PATCH] Revert "feat: better experience with correct focus" This reverts commit 3203f9426e497d2de0b8dad29788efdf08232a8c. --- src/components/FileExplorer.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/FileExplorer.tsx b/src/components/FileExplorer.tsx index 904bd2b..13bba7f 100644 --- a/src/components/FileExplorer.tsx +++ b/src/components/FileExplorer.tsx @@ -182,13 +182,16 @@ function ListView({ const listRef = React.useRef(null) const { focusedNode, nodes } = visibleNodes React.useEffect(() => { - if (listRef.current && focusedNode) { + if (listRef.current && focusedNode?.path) { const index = nodes.findIndex(node => node.path === focusedNode.path) if (index !== -1) { listRef.current.scrollToItem(index, 'smart') } } - }) + }, [focusedNode?.path]) + // For some reason, removing the deps array above results in bug: + // If scroll fast and far, then clicking on items would result in redirect + // Not know the reason :( const goToCurrentItem = React.useCallback(() => { const targetPath = platform.getCurrentPath(metaData.branchName)