@wordpress/ui: Compat overlay slot — viewport-sized containing block#78441
@wordpress/ui: Compat overlay slot — viewport-sized containing block#78441ciampo wants to merge 1 commit into
Conversation
|
Size Change: +26 B (0%) Total Size: 7.97 MB 📦 View Changed
ℹ️ View Unchanged
|
4cc2de6 to
c5292dc
Compare
The body-level compat overlay slot was `position: fixed; top: 0; left: 0` with no width/height. With its only child being a `position: absolute` overlay positioner — which doesn't contribute to its parent's intrinsic size — the slot collapsed to 0×0. Absolutely-positioned children inside a zero-width containing block fall back to shrink-to-fit constrained by zero available width, which forces `width: auto` popups to their min-content width (the longest unbreakable word). The most visible symptom: long-text tooltips wrapped to one word per line. Stretch the slot to viewport size (`inset: 0`) so portaled overlay positioners get a sane containing block, and add `pointer-events: none` so the now-full-bleed slot doesn't intercept clicks across the page. Each opt-in component (Tooltip, Autocomplete, Select) re-enables `pointer-events: auto` on its own positioner so portaled content stays interactive.
c5292dc to
6685f49
Compare
|
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 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. |
|
Flaky tests detected in 6685f49. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/26104199597
|
| /* Re-enable interaction inside the compat overlay slot. */ | ||
| pointer-events: auto; |
There was a problem hiding this comment.
Having to add these to each component is not great… Did we consider adding something like this directly to the slot styles?
.slot > * {
pointer-events: auto;
}Maybe in a low @layer so it never has to fight with anything.
| /* Physical, not logical: `inset-inline-start: 0` resolves to | ||
| * `right: 0` in RTL. */ | ||
| /* stylelint-disable-next-line plugin/use-logical-properties-and-values -- See comment above. */ |
What?
Stretch the
@wordpress/uicompat overlay slot to viewport size so portaled overlays — most visibly long-textTooltippopups — stop wrapping to their min-content width (one word per line).Surfaced while migrating consumers to the new
Tooltipin #78411.Why?
The slot was
position: fixed; top: 0; left: 0;with no width or height — its only DOM child isposition: absolute, which doesn't contribute to the parent's intrinsic size, so the slot collapsed to 0×0. Absolutely-positioned popups inside a 0-width containing block fall back to shrink-to-fit against zero available width → min-content width (longest unbreakable word).The legacy
@wordpress/componentsTooltipdidn't have this problem because it portaled intodocument.body.Measurement from a minimal browser repro (identical popup CSS in both rows)
position: fixed; top: 0; left: 0;(was)position: fixed; inset: 0;(this PR)How?
position: fixed; inset: 0; pointer-events: none;— viewport-sized containing block, withpointer-events: noneso the now-full-bleed slot doesn't intercept clicks on the rest of the page.pointer-events: autoon its own positioner (pointer-eventsis inherited, so the slot'snonewould otherwise propagate to portaled content).Opt-in audit — which components currently route their portal into the compat slot
TooltipAutocompleteSelectPopover,Dialog,AlertDialog, andDrawerdo not opt in (they use base-ui's defaultdocument.bodyportaling), so they need nopointer-events: autochange.Files touched
packages/ui/src/utils/css/wp-compat-overlay-slot.module.css— slot layout +pointer-events: none.packages/ui/src/tooltip/style.module.css—pointer-events: autoon positioner.packages/ui/src/form/primitives/autocomplete/style.module.css— same.packages/ui/src/form/primitives/select/style.module.css— same.packages/ui/CHANGELOG.md— entry under Bug Fixes.Testing Instructions
Existing playground fixtures already mount the compat slot and render an
@wordpress/uiTooltip/Select/Autocompleteinside a@wordpress/componentsoverlay — they're the natural regression-watch surface:Popovervariant). Open the modal/popover, hover the Hover me tooltip trigger, and confirm the tooltip text renders on one line (before this PR it wrapped to roughly one word per line).SelectandAutocompletepopups inside the modal/popover and confirm clicking an item still selects it (verifies the per-componentpointer-events: autois in place).npm run test:unit -- packages/ui/src/utils/test/wp-compat-overlay-slot packages/ui/src/tooltip/test packages/ui/src/form/primitives/autocomplete/test packages/ui/src/form/primitives/select/test— 52 tests should pass.Testing Instructions for Keyboard
No keyboard-surface changes. Focus order,
Escto dismiss, etc. behave as before — this PR only adjusts floating layout and pointer-events.Screenshots or screencast
inset: 0)Use of AI Tools
This PR was authored with assistance from Cursor (Claude). All changes were reviewed by a human before being committed; the slot change was validated against a minimal standalone browser repro, and unit tests + lint were exercised locally before pushing.