WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.34k stars 4.13k forks source link

CustomSelectControl V2 popover renders below position: sticky elements #63180

Open ciampo opened 2 months ago

ciampo commented 2 months ago

As flagged in https://github.com/WordPress/gutenberg/pull/62821 (see PR description):

The V2 version of the component automatically "flips" the popover to render on top of the trigger if there isn't enough space below it. In the specific example of the block toolbar, this causes a small visual glitch when the browser's viewport is short enough to cause the flip:

Screenshot 2024-06-25 at 12 13 32

This glitch happens because the block toolbar's header has position: sticky, which causes it to render on top of the select popover despite a lower z-index.

A few preliminary ideas that try to avoid the problem rather than solving it:

I'm not sure we can solve this systematically at the CSS level. At most we could look into where in the DOM the popover is rendered, and consider portalling it so that it plays better with the stacking context?

ciampo commented 2 months ago

While https://github.com/WordPress/gutenberg/pull/63357 should avoid the issue for the V2 legacy adapter (soon to be the new V1) component, we will still need to understand how to best solve this for the V2: