fix(Portal): apply position:relative so z-index creates a stacking context#602
Open
sridhar-3009 wants to merge 1 commit into
Open
Conversation
…ntext (vuetifyjs#554) Portal hands out a computed z-index via its slot prop, but `z-index` is only effective on *positioned* elements (position: relative/absolute/ fixed/sticky). When SnackbarPortal teleports to `<body>`, the wrapper Atom div had `position: static` (the browser default), so the computed z-index was silently ignored and the snackbar sank beneath any positioned page chrome (e.g. `.app-shell-content { z-index: 1 }`). Fix: add `position: 'relative'` alongside `zIndex` in SnackbarPortal's `getSlotProps`, giving the wrapper a stacking context without affecting its visual position. Also document the requirement in Portal's slot-prop JSDoc so other consumers know to position the element they apply `zIndex` to.
Contributor
|
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.
Closes #554
Problem
Portal.vueexposeszIndexas a slot prop but is itself renderless — it renders no DOM element.SnackbarPortalapplies thatzIndexto anAtomwrapper div viastyle: { zIndex }, but the div hasposition: static(the browser default). CSS ignoresz-indexon non-positioned elements, so the computed value has no effect. When a snackbar teleports to<body>it lands behind any positioned page chrome (e.g..app-shell-content { z-index: 1 }) regardless of how large its stack-assigned z-index is.Reproduced via #279: docs'
.app-shell-content { z-index: 1 }sat above a body-fallback Snackbar.Fix
Add
position: 'relative'alongsidezIndexinSnackbarPortal.getSlotProps.position: relativewithout offsets is visually neutral — the element stays in normal flow at its natural position — but creates a stacking context soz-indextakes effect.Also update
Portal'sPortalSlotProps.zIndexJSDoc to document the contract: the element receivingzIndexmust be positioned.Changes
SnackbarPortal.vue:getSlotPropsnow returnsstyle: { position: 'relative', zIndex }and theSnackbarPortalSlotPropstype is updated to matchPortal.vue:PortalSlotProps.zIndexgains a@remarksnoting the positioned-element requirement