Skip to content

Popover flips even when there's space to render. #7897

Open
@endaquigley

Description

@endaquigley

Provide a general summary of the issue here

The Popover component flips even when there's space to render.

The position calculations don't seem to take the maxHeight prop into account.

Screen.Recording.2025-03-09.at.23.43.34.mov

https://codesandbox.io/p/sandbox/react-aria-popover-placement-57fhmq

🤔 Expected Behavior?

The Popover should only flip when there's not enough room to render the content.

😯 Current Behavior

The Popover component flips even when there's space to render the scrollable content.

I included a 1px margin at the top of the Button so there's more space above the component now. As the Popover can't render the full content it switches to the axis that has more space.

💁 Possible Solution

From what I can tell calculatePositionInternal doesn't take the maxHeight prop into account.

https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/overlays/src/calculatePosition.ts#L355C15-L355C39

🖥️ Steps to Reproduce

  1. Render a Select with a Popover that has a maxHeight prop.
  2. Open the Select and notice how the placement prop is not respected.

Version

1.7.0

What browsers are you seeing the problem on?

Chrome

What operating system are you using?

macOS 15.3.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions