fix(dismissable): restore layer style mirror after framework style rewrites - #3177
fix(dismissable): restore layer style mirror after framework style rewrites#3177spokodev wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 1d50f28 The changes in this PR will be included in the next version bump. This PR includes changesets to release 86 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Went through this one in detail — the fix and the new test coverage both hold up. The approach (a The test file is also a real addition on its own merits — One thing worth a second look, not blocking: The bigger gap is that CI has never actually run on this commit — |
Fixes #3148
Problem
The layer stack mirrors its metadata (
--layer-index,--nested-layer-count,--z-index,data-nested,data-has-nested) onto style targets likeDrawer.Backdropimperatively viastyle.setProperty, but only when layers are added or removed. Frameworks own the same elements'styleand replace the inline style wholesale on re-render — for the drawer, every drag pointermove updates--drawer-swipe-progresson the backdrop, so the first drag frame erases the mirrored variables andz-index: calc(100 + var(--layer-index))breaks for the rest of the layer's lifetime.Fix
Watch each mirrored element's
styleattribute with aMutationObserverand re-apply the metadata when it disappears while the layer is still in the stack. The observer is a no-op when the metadata is present (no loops: re-applying triggers one callback that sees--layer-indexset and returns), keeps whatever the framework wrote (--drawer-swipe-progresssurvives), and is disconnected when the layer is removed so cleared styles stay cleared.Tests
restores mirrored metadata after a framework rewrite of the style attributefails onmain(--layer-indexstays empty aftersetAttribute("style", ...)) and passes with this change. A second test pins that removal still clears the mirror and the observer stops restoring. Dismissable suite: 15 passed.