CustomSelectControlV2: Flip legacy popover upward when space below trigger is insufficient#77947
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @jayclydeTags. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Thanks for digging into this! After looking at this with the linked context (#63357, #63180, #62821) and tracing the actual rendering, I'd suggest closing this PR in favor of a fix at a different layer. Details below. Concerns with the current implementation
What's actually going onReading Ariakit's source, That single fact explains both issues:
Both issues collapse into a single root cause: the popover renders inline, in stacking contexts and overflow containers it shouldn't be subject to. Suggested pathWe should look into potentially enabling the underlying
cc @mirka since this is partially related to the work we're actively doing re. reducing/simplifying z-stacking in Gutenberg. |
What?
Closes #76126
Fixes an issue in the
CustomSelectControlV2legacy adapter where the popover was forced to never flip. This caused dropdowns to always open downward and get clipped by the viewport when used near the bottom of the Style Panel.This change introduces a viewport-aware flip behavior only for the legacy adapter. The popover flips upward when there isn’t enough space below for proper interaction, and applies additional padding to prevent it from rendering beneath the sticky header. The non-legacy component remains unchanged.
Why?
PR #63357 intentionally disabled flipping for the legacy adapter to align with downshift-based component. However, this introduced a regression (#76126) where dropdowns near the bottom of the Style Panel could become partially or fully inaccessible due to viewport clipping.
The fix preserves the original no-flip behavior in the common case (enough space below the trigger) so the block toolbar glitch is not reintroduced, while allowing a flip only when the space below is genuinely insufficient and ensuring it remains unobstructed by the panel’s header.
How?
On
onPointerDownof the trigger button:FLIP_THRESHOLD(currently set to 150px),flipis enabled for that interactionAdditionally, when the popover flips upward,
overflowPadding={50}is applied to offset it from the top edge of the viewport, preventing it from appearing beneath the block toolbar’s sticky header.Testing Instructions
Screenshots or screencast
Screen.Recording.2026-05-05.at.4.01.44.PM.mov
Use of AI Tools