Modal: Render inside the overlay legacy slot#77757
Draft
ciampo wants to merge 1 commit intomigrate/popover-to-overlay-legacy-slotfrom
Draft
Modal: Render inside the overlay legacy slot#77757ciampo wants to merge 1 commit intomigrate/popover-to-overlay-legacy-slotfrom
ciampo wants to merge 1 commit intomigrate/popover-to-overlay-legacy-slotfrom
Conversation
Change the Modal's portal target from \`document.body\` to \`getOverlayLegacySlot()\` so the modal lives inside the \`.wp-overlay-legacy\` stacking context. Update the aria-helper to walk up from the modal element to the body, hiding non-modal siblings at each level. The previous algorithm only inspected direct body children, which would have aria-hidden the overlay legacy slot wrapper itself; the new algorithm preserves the existing nested-modal semantics (an outer modal becomes aria-hidden when an inner modal opens) regardless of how deep the modal is portaled. The \`.components-modal__screen-overlay\` z-index (100,000) and the 14 sibling overlay z-indexes at 1,000,001 are unchanged; they now stack relative to the legacy slot's stacking context.
|
Size Change: +24 B (0%) Total Size: 7.82 MB 📦 View Changed
ℹ️ View Unchanged
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Stacked on top of #77756.
Move the
@wordpress/componentsModal portal fromdocument.bodytogetOverlayLegacySlot(), and update the aria-hide algorithm so it remains correct after the wrapper is introduced.Why?
Continuation of the legacy-slot migration. With the Modal inside
.wp-overlay-legacy, every legacy@wordpress/componentsoverlay shares the same stacking context, so a future@wordpress/uiTooltip rendered inside a@wordpress/componentsModal will stack above the modal by virtue of its slot being above the legacy slot — without any per-instance plumbing.The
.components-modal__screen-overlayz-index (100,000) and the 14 sibling overlay z-indexes at 1,000,001 (e.g..components-confirm-dialog) are unchanged. They now stack relative to the legacy slot's stacking context, preserving the existing modal-above-popover ordering.How?
packages/components/src/modal/index.tsx: changecreatePortal(modal, document.body)tocreatePortal(modal, getOverlayLegacySlot()).packages/components/src/modal/aria-helper.ts: rewritemodalize()to walk up frommodalElementto<body>and hide non-modal siblings at each level. The previous algorithm only inspected direct body children — once the modal is portaled into a body-level wrapper (the slot), the wrapper itself would have been hidden, taking the modal subtree with it. The new algorithm:modalElement.Testing Instructions
Open the post editor. Trigger any modal (e.g. block-editor Rename Block, Duplicate, Block Visibility). Verify the modal opens, traps focus, and dismisses with
Escapeand the close button.In DevTools, walk up from
.components-modal__screen-overlay. The modal should be inside<div class="wp-overlay-legacy">rather than directly under<body>.Open a confirm dialog (e.g. confirm a destructive operation). Verify it stacks above the modal as before.
Nested modal (e.g. Block Manager inside Preferences). Verify the outer modal becomes aria-hidden when the inner opens, and is restored on inner close.
Run the unit suite:
Testing Instructions for Keyboard
Open any modal.
TabandShift+Tabshould cycle within the modal (focus trap).Escapeshould close it and return focus to the trigger.Use of AI Tools
This PR was authored with assistance from AI tooling (Claude). All code, copy, and structural decisions were reviewed by a human contributor.