Merge pull request #3159 from overleaf/ta-outline-item-scroll-fix

Fix Outline Item Scroll for Highlighted Parents

GitOrigin-RevId: e67ca4a3043cd60536dbd389438b5a67d6f38efa
This commit is contained in:
Timothée Alby 2020-09-15 14:48:27 +02:00 committed by Copybot
parent 3f99a5ca73
commit d0b6e877dc

View file

@ -55,18 +55,16 @@ function OutlineItem({ outlineItem, jumpToLine, highlightedLine }) {
useEffect(
() => {
const wasHighlighted = isHighlightedRef.current
const isNowHighlighted = highlightedLine === outlineItem.line
isHighlightedRef.current = isHighlighted
isHighlightedRef.current = isNowHighlighted
if (!wasHighlighted && isNowHighlighted) {
if (!wasHighlighted && isHighlighted) {
scrollIntoViewIfNeeded(titleElementRef.current, {
scrollMode: 'if-needed',
block: 'center'
})
}
},
[highlightedLine, titleElementRef, isHighlightedRef]
[isHighlighted, titleElementRef, isHighlightedRef]
)
// don't set the aria-expanded attribute when there are no children