primitives icon indicating copy to clipboard operation
primitives copied to clipboard

[DropdownMenu] Ensure menu height is constrained by the view height

Open chaance opened this issue 4 years ago • 3 comments
trafficstars

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.

chaance avatar Jan 11 '21 22:01 chaance

@benoitgrelard happy to look at this. I think I get the gist but could you provide some more context on the issue?

andy-hook avatar Apr 16 '21 14:04 andy-hook

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.

benoitgrelard avatar Apr 16 '21 19:04 benoitgrelard

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:

image

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.

andy-hook avatar Apr 19 '21 09:04 andy-hook