[6.x] Introduce a shared z-index ladder for the CP - #19501
Draft
brianjhanson wants to merge 1 commit into
Draft
Conversation
📚 Storybook previews@craftcms/ui — open Storybook Changed components:
resources/js — open Storybook No changed components detected in this Storybook. |
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.
Description
Every z-index in the CP was an independent guess. The modern stack alone spanned
1,2,3,10,99,100,1000,1001,10000,10001,10002, with numbers picked defensively against each other —Modal.vuecarried a@TODO make this less fragile/weird, the slideout shade sat at99only to be "one below" a100chosen elsewhere, and two pairs collided outright (CpSidebartied with legacy.promptat1001; the element-editor's sticky header tied with legacy.progressbarat1000).This adds a named ladder and moves the modern stack onto it.
The ladder is declared in
packages/craftcms-ui/src/styles/shared/z-layers.cssas--c-z-*custom properties and mirrored inpackages/craftcms-ui/src/constants/z-layers.tsasZLayerfor the places that need a number in JS. A unit test asserts the two can't drift. There are two bands: local (behind-1→sticky10) for stacking inside a component's own stacking context, and page-level (page-header2000→debug9000) for surfaces that compete with the rest of the CP. Rungs are spaced by 1000 so a new layer can be slotted in without a renumber.The page-level band starts at
2000deliberately: the legacy CP bundle still uses raw numbers topping out at1001, so every rung clears legacy without legacy having to be renumbered first — which matters because the two stacks share a page on anyCpScreenResponsescreen. Legacy SCSS is intentionally untouched;docs/z-layers.mdcarries a mapping table and says to port a legacy surface onto the ladder when you port the surface itself.Two things turned up along the way that the docs now record:
OverlayControllerdefaults tozIndex: 9999and writes it inline on a wrapping<dialog>, socraft-popover,craft-action-menu,craft-tooltip,craft-select-rich, andcraft-comboboxwere floating above everything by default rather than by design. Each now passes its rung through_defineOverlayConfig().craft-dialogis a Lion modal dialog, so it opens viashowModal()and lands in the browser's top layer — above every z-index regardless of value. No rung can order against it.markdown-field.css's::part(dialog) { z-index: 10001 }was dead code:craft-popoveronly exposespart="popup", and an inline style beats::partanyway. Removed.Garnish is standalone and can't import
@craftcms/ui, soDrag'shelperBaseZindexdefault moves1000→3000to match--c-z-drag, with a pointer comment; its docs and two assertions are updated to match.Two intentional behavior changes worth knowing: the element-editor header now clears legacy
.progressbar, and the Vue sidebar now sits above legacy.prompt/login rather than tying with them.Verified with the
@craftcms/ui(670) and Garnish (375) unit suites, the new sync test,vp fmt --check, andoxlint. No PHP changed, socomposer ciwasn't run. The Storybook browser suite hasn't been run against this yet and is worth a pass before merge.