Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10964
Summary
When a popover repositions (e.g. on window resize),
updatePosition()inuseOverlayPositiontemporarily sets the overlay'smax-heightto the full viewport height before measuring. Scroll containers that usemax-height: inherit(like the RAC ListBox) briefly grow, and the browser clamps theirscrollToptoscrollHeight - viewportHeight. The existing scroll-anchor restore only ran when real DOM focus was inside the scroll container, so in a ComboBox (where focus stays in the input) the position was never restored. The list jumped up, and the last options couldn't be reached.Changes:
getFocusedElementWithin()helper returns the focused element inside the scroll container, either via real DOM focus or via the active element'saria-activedescendant. The existing top/bottom anchor logic now uses this element, so a keyboard-highlighted option stays in place when the popover repositions. The lookup usesgetRootNode()andnodeContainsso it works in shadow DOM.scrollTopis saved before themax-heightreset and restored afterward when there is no anchor element (e.g. the user scrolled with the mouse).Out of scope: the issue also describes a continuous reposition loop on Windows, where a temporary page scrollbar fires
visualViewportresize events. This PR stops the visible scroll jumping, but it doesn't stop the extra repositions themselves. That could be a follow-up if wanted.📝 Test Instructions
Regression test: added
preserves the scroll position of the scroll container when repositioningtopackages/react-aria/test/overlays/useOverlayPosition.browser.test.tsx. It scrolls an overlay's list to the bottom, fires aresize, and asserts thatscrollTopis unchanged.expected 2280 to be 2522, i.e.scrollTopwas clamped).yarn test:browser packages/react-aria/test/overlays/useOverlayPosition.browser.test.tsx # 9/9 passed
yarn test packages/react-aria/test/overlays packages/react-aria-components/test/ComboBox.test.js # 244/244 passed
Manual: In Storybook (React Aria Components → ComboBox), opened the list, scrolled to the last item, resized the window — list stayed in place. With the keyboard, ArrowDown past the old cap keeps the highlighted option visible. Tested on Windows 11 / Chrome.
Not covered: the automated test covers the mouse-scroll path (no focused element). The virtual-focus (
aria-activedescendant) path was verified manually only. Not tested: RTL, touch, or screen readers [edit if you did test any of these].Release impact
✅ PR Checklist
🧢 Your Project