Skip to content

fix: popover max height in portal containers on scrolled pages - #11073

Open
okeken wants to merge 3 commits into
adobe:mainfrom
okeken:fix/11072-popover-max-height-portal
Open

okeken wants to merge 3 commits into
adobe:mainfrom
okeken:fix/11072-popover-max-height-portal

Conversation

@okeken

@okeken okeken commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #11072

Summary

When overlays are portalled into a positioned container, a popover's max-height shrinks by the page scroll and can reach 0. It should use the space visible below its trigger.

getMaxHeight compared the bottom of the window with the popover's position in the container. This subtracts the container's top in the viewport, so both use the same coordinates.

The one-line change in the issue fixes the reported case, but makes popovers too tall with a scrolled position: relative body, or with a portal container when pinch zoomed.

📝 Test Instructions

  1. Run yarn start-parcel3 and open React Aria Components → Popover → Scrolled Portal Container.
  2. With isBodyPositioned off, scroll until the button is near the top, then open the popover. It should fill the space below the button. Without this fix, it collapses to an empty sliver.
  3. Turn isBodyPositioned on and repeat. It should look the same. This case already works on main, and checks that the fix doesn't break it.

This StackBlitz compares the released code, the one-line change and this fix.

yarn test:browser useOverlayPosition passes in Chromium and Firefox locally, and in WebKit on CI. The new portal container test fails without this fix. Pinch zoom is tested with a mocked viewport, not on a real device.

Release impact

  • Only changes docs, tests, CI, or development tools. Nothing shipped to users changes.
  • Fixes a bug or improves existing code without changing how apps use it.
  • Adds a feature or API while keeping existing usage working.
  • May break existing usage or require changes in apps that use this code.

✅ PR Checklist

  • I followed the contributing guide.
  • I tested this change locally and included the results in Test Instructions, or explained why testing does not apply.
  • I understand and can explain every change in this PR. If I used AI assistance, I followed the AI contribution guidance.

AI assistance was used for this change.

🧢 Your Project

The bottom of the visual viewport was never converted to the container's
coordinates, so the max height shrank by the page scroll when overlays were
portalled into a positioned container. Use the container's position in the
viewport to convert it.
yihuiliao
yihuiliao previously approved these changes Dec 2, 2026

@snowystinger snowystinger left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here look bigger than in the stackblitz, what happened?
can you include a storybook story so we can manually verify the PR?

also, it looks like a human wasn't included in the review before submitting, please have your human review your code

@okeken

okeken commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

The changes here look bigger than in the stackblitz, what happened? can you include a storybook story so we can manually verify the PR?

also, it looks like a human wasn't included in the review before submitting, please have your human review your code

Thank you for the review!

I have gone through this myself and decided to stick with a much simpler version. The first one passed the container's position through two functions as an extra parameter, while the StackBlitz used a global, so it looked smaller. It's now stored with the container's other dimensions.

I have also added a story to test it locally (steps are in the description) and updated the StackBlitz to match. The story sets shouldFlip: false so the popover always opens below, which is where the bug happens.

I am happy to answer any further questions or concerns you may have.

Cheers!

@snowystinger snowystinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, that looks better. I've verified the behaviour in the storybook and ran chromatic on this build, it passed.

@okeken

okeken commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Brilliant! @yihuiliao the previous approval was dismissed by the new commit, have you got a minute to take a second look? Thank you.

@okeken
okeken requested a review from yihuiliao December 4, 2026 17:42
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.

Popover maxHeight shrinks by the page scroll offset when overlays portal into a non-viewport container

3 participants