Merge pull request #3551 from overleaf/msm-filetree-increase-scroll-timeout

Increased timeout to perform selected file scroll

GitOrigin-RevId: 4bfa8e5a329dded4e7599d3df11625ed19c921e8
This commit is contained in:
Jakob Ackermann 2021-01-12 11:24:27 +00:00 committed by Copybot
parent 9d47b05486
commit a3176e2b6b

View file

@ -23,14 +23,18 @@ function FileTreeItemInner({ id, name, isSelected, icons }) {
useEffect(() => { useEffect(() => {
const item = itemRef.current const item = itemRef.current
if (isSelected && item) { if (isSelected && item) {
// we found scrolling doesn't happen unless a explicit delay is introduced // we're delaying scrolling due to a race condition with other elements,
// mainly the Outline, being resized inside the same panel, causing the
// FileTree to have its viewport shrinked after the selected item is
// scrolled into the view, hiding it again.
// See `left-pane-resize-all` in `file-tree-controller` for more information.
setTimeout(() => { setTimeout(() => {
if (item) { if (item) {
scrollIntoViewIfNeeded(item, { scrollIntoViewIfNeeded(item, {
scrollMode: 'if-needed' scrollMode: 'if-needed'
}) })
} }
}, 10) }, 100)
} }
}, [isSelected, itemRef]) }, [isSelected, itemRef])