Skip to content

Commit 43c7b0a

Browse files
authored
fix(scrollIntoViewport): add root to scrollParents (#8981)
1 parent 678ea7e commit 43c7b0a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/@react-aria/utils/src/scrollIntoView.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ export function scrollIntoViewport(targetElement: Element | null, opts?: ScrollI
151151
} else {
152152
let scrollParents = getScrollParents(targetElement);
153153
// If scrolling is prevented, we don't want to scroll the body since it might move the overlay partially offscreen and the user can't scroll it back into view.
154+
if (!isScrollPrevented) {
155+
scrollParents.push(root);
156+
}
154157
for (let scrollParent of scrollParents) {
155158
scrollIntoView(scrollParent as HTMLElement, targetElement as HTMLElement);
156159
}

0 commit comments

Comments
 (0)