Skip to content

fix(react-aria): handle position fixed in getTotalOffsetTop to prevent scroll jump#35926

Open
themechbro wants to merge 1 commit intomicrosoft:masterfrom
themechbro:fix/dropdown-scroll-jump
Open

fix(react-aria): handle position fixed in getTotalOffsetTop to prevent scroll jump#35926
themechbro wants to merge 1 commit intomicrosoft:masterfrom
themechbro:fix/dropdown-scroll-jump

Conversation

@themechbro
Copy link
Copy Markdown

Fixes: #35921

When a Dropdown with inlinePopup is opened inside a scrollable container (like a Dialog), a race condition between createPositionManager and useActiveDescendant causes the parent container to violently scroll to the top.

This occurs because the active descendant controller fires scrollIntoView while the listbox is still temporarily pinned with position: fixed. Because fixed elements report an offsetTop of 0, the getTotalOffsetTop function calculates a negative distance, triggering the browser to scroll to the top of the container.

The Solution:
Updated the getTotalOffsetTop utility in react-aria to account for elements removed from the normal document flow.

Added a check for position: fixed using getComputedStyle.

If the element is fixed, it bypasses the unreliable offsetTop property and instead uses getBoundingClientRect().top to accurately calculate the visual distance to the scroll parent.

Fallbacks to standard offsetTop math for all standard relative/absolute elements.

Testing:

Verified the math fix resolves the -111px scroll jump in the provided reproduction environment without breaking standard relative scroll calculations.

@themechbro themechbro requested a review from a team as a code owner March 30, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dropdown with inlinePopup scrolls parent container to top when opened inside a scrollable Dialog

1 participant