Skip to content

fix: Menu popover doesn't flip when a user-set maxHeight can't fit below the trigger - #10470

Open
timges wants to merge 5 commits into
adobe:mainfrom
timges:fix/height-flip-trigger-maxheight
Open

fix: Menu popover doesn't flip when a user-set maxHeight can't fit below the trigger#10470
timges wants to merge 5 commits into
adobe:mainfrom
timges:fix/height-flip-trigger-maxheight

Conversation

@timges

@timges timges commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Closes #10176.

Menu popovers with a user-set maxHeight weren't flipping to the other side of the trigger when they no longer fit below it. calculatePositionInternal compared the overlay's current, already-clamped height against the available space, so once the overlay had been clamped down to fit on an earlier pass, it kept looking like it fit and never re-evaluated the flip. This folds the user-provided maxHeight into that height-axis comparison so the flip decision is based on the overlay's true requested size instead of the stale clamped one.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices
  • I understand every change in this PR and can explain why it's there.
  • If AI-assisted, I followed our AI contribution guidance and pointed my assistant at CLAUDE.md.

📝 Test Instructions:

  • yarn jest packages/react-aria/test/overlays/useOverlayPosition.test.tsx — 16/16 passing, including a new regression test for the maxHeight flip fix and an RTL case confirming overlays that should stay put still don't flip.
  • yarn format:check — clean.
  • yarn oxlint on the two changed files — clean (the full repo run has pre-existing, unrelated errors in scripts/ and storybook config files on main).
  • Manual: render a Menu/Popover near the bottom of the viewport with a maxHeight larger than the remaining space below the trigger; confirm it flips above the trigger instead of staying clamped below it, in both LTR and RTL.

🧢 Your Project:

Spectrum Metrics

timges added 5 commits August 13, 2026 22:12
…low the trigger (adobe#10176)

Folds the user-provided maxHeight into the height-axis flip-trigger comparison in calculatePositionInternal, so the decision to flip is based on the overlay's true requested size instead of a stale clamped height left over from a previous positioning pass.
Ground the new adobe#10176 flip-regression test titles in behavior instead of
the issue number, and move them next to the existing sibling maxHeight
test instead of after an unrelated arrow test.
Pare comments down to the non-obvious why (the offsetHeight mock and
the maxHeight fold-in rationale); drop ones that just restated code or
assertions already visible nearby.
beforeEach already resets it before every test, so the declaration-time
value was never actually observed.
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.

Menu popover not flipping

1 participant