feat: better experience with correct focus

This commit is contained in:
EnixCoda 2020-10-26 20:53:33 +08:00
parent 2227039bbf
commit 3203f9426e
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD

View file

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