Repository navigation
Conversation
…ault
The dropdown popover was rendered inline in the DOM, which subjected
it to the trigger's ancestor stacking contexts (e.g. the block
toolbar's `position: sticky` header) and `overflow` containers (e.g.
the Style Panel). This caused the popover to be covered or clipped
near the bottom of the editor sidebar.
Internally, the v2 component now accepts `portal` and `portalElement`
props that forward to the underlying Ariakit `SelectPopover`. The
legacy `CustomSelectControl` adapter uses `useSlot('Popover')` to
portal the dropdown into the registered `Popover.Slot` by default,
falling back to the document `body` when no slot is available. A new
`inline` prop is exposed on the legacy adapter as an escape hatch for
consumers that need the previous inline rendering.
The legacy-only `flip={ ! isLegacy }` override (added in #63357 to
mask the same stacking glitch) is now applied only when the popover
is not portaled — once portaled, Floating UI's flipping behavior
matches user expectations near viewport edges.
|
Size Change: +32 B (0%) Total Size: 7.95 MB 📦 View Changed
ℹ️ View Unchanged
|
…t.body Returning `element.ownerDocument.body` directly from the `portalElement` callback caused Ariakit to write a `portal/...` id onto `<body>` and skip cleanup, since `body.isConnected` is `true`. Hand `undefined` to Ariakit when no `Popover.Slot` is registered so its default kicks in: a fresh wrapper div appended to `body` and properly removed on unmount.
|
Flaky tests detected in e27ebde. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25424563015
|
So the default portaling into `Popover.Slot` is exercised in Storybook, mirroring the editor's setup.
…kit default
Pass `flip={ true }` for the non-inline branch instead of `undefined` so
the behavior cannot drift if Ariakit's default ever changes. Matches the
existing local convention of passing explicit values for popover props
(`gutter`, `slide`, etc.).
The `flip={ false }` override for the legacy adapter was a workaround
for a stacking-context glitch with the sticky block toolbar (#63180,
#63357). Now that the popover is portaled by default, the popover
escapes ancestor stacking contexts and the workaround is no longer
needed. Always let Floating UI flip near viewport edges.
Consumers who opt back into inline rendering via `inline` will also
get the default flipping. If they happen to render inside a sticky
toolbar context they may see the original glitch — but that's the
trade-off they're choosing by opting out of portaling.
|
Update: Local tests show that the approach tested in this PR would fix both #76126 and #63180. However, we're in the middle of developing a new package of components ( After With that in mind, I'll close this PR, since it would delay the plan described above. We can always reconsider the decision and merge this PR in case. (cc @WordPress/gutenberg-components ) |
Closes #76126
Closes #63180
Follow up to #63357
Alt to #77947
What?
Render the legacy
CustomSelectControldropdown popover in a React portal by default — into the registeredPopover.Slot, with adocument.bodyfallback — so it can no longer be clipped by ancestoroverflowcontainers (e.g. the Style Panel) or covered by sticky elements (e.g. the block toolbar).A new
inlineprop is exposed as an opt-out for consumers that need the previous inline DOM rendering.Why?
The dropdown rendered inline in the DOM, so it inherited the trigger's ancestor stacking contexts and
overflowcontainers. That causes #63180 (toolbar overlap) and #76126 (Style Panel clipping). #63357 disabled flipping to mask #63180 and left #76126 unfixed. Portaling addresses both at the root.How?
custom-select-control-v2/custom-select.tsx) accepts and forwardsportalandportalElementto the AriakitSelectPopover.CustomSelectControlreadsPopover.SlotviauseSlot('Popover')and defaults toportal=true.flip={false}workaround now applies only when not portaled.inlineprop on the legacy adapter restores the previous behavior (no portal, no flip).API and design notes
inlinemirrorsPopover's existing public prop. Same name, same default (false).z-index: 1000000on the popover was a no-op while inline (it only operated within the trigger's stacking context). Once portaled it stacks atbody/Popover.Slotlevel, alongsidePopoverandMenu.Popover, and the value is meaningful.CustomSelectControlV2) gains the new props through pass-through. No default change.Testing Instructions
inlineto a legacyCustomSelectControland confirm the previous behavior is preserved (popover rendered inline next to the trigger, no flipping near viewport edges).Places in Gutenberg to spot-check
The legacy
CustomSelectControlis used in many places. A few representative spots covering different mounting contexts:Style Panel (inspector controls, in a scroll container):
FontFamilypicker —packages/block-editor/src/components/font-family/index.jsFontAppearancepicker —packages/block-editor/src/components/font-appearance-control/index.jsFontSizePicker(select variant, when many presets exist) —packages/components/src/font-size-picker/font-size-picker-select.tsxBorderRadiusControl— viaPresetInputControl(packages/block-editor/src/components/preset-input-control/index.js)SpacingSizesControl— viaPresetInputControlDimensionControl—packages/block-editor/src/components/dimension-control/index.jspackages/block-editor/src/hooks/position.jsEditor (outside the Style Panel):
packages/block-editor/src/components/date-format-picker/index.jsCustomSelectControl)packages/components/src/validated-form-controls/components/custom-select-control.tsxFor each: open the dropdown via mouse and via keyboard (Tab → Enter/Space, Up/Down to navigate, Enter to select, Escape to close, focus returns to trigger).
Testing Instructions for Keyboard
Screenshots or screencast
TODO / Follow-ups
CustomSelectControlconsumers all live in the parent document. If a cross-document case surfaces, followPopover's<Fill>+StyleProviderpattern.Use of AI Tools