primitives
primitives copied to clipboard
[DropdownMenu] Ensure menu height is constrained by the view height
See https://github.com/radix-ui/primitives/discussions/375#discussioncomment-275343
Yeah I believe that's to do with the fact that the menu can overflow the view now and we'd like to constrain its height (at least in some situations). I wanted to do that before xmas but didn't have time to get to it.
@benoitgrelard happy to look at this. I think I get the gist but could you provide some more context on the issue?
Had a call with @andy-hook about this and we decided for now to wait and see what new requirements are introduced by adding submenu support to Menu and adding MenuBar to our portfolio to see what use cases emerges.
For posterity – the issue is with tall menus exceeding the viewport height. It’s possible to get into situations where popper has nowhere else to place the menu, causing layout shifting and other overflow problems, for example:

The proposed solution is to cap the max height of the menu relative to the viewport and provide an overflow scroll (native would be fine initially)
Position logic is calculated via getPlacementData and some thought would be needed on the best way to supply additional context for these calculations.