Revert "feat: better experience with correct focus"

This reverts commit 3203f9426e.
This commit is contained in:
EnixCoda 2020-10-28 00:07:52 +08:00
parent 8c970d7fb4
commit 396af20fa4
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD

View file

@ -182,13 +182,16 @@ function ListView({
const listRef = React.useRef<FixedSizeList>(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)