mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
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:
parent
3f99a5ca73
commit
d0b6e877dc
1 changed files with 3 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue