Repository navigation
Description
Environment
Development/Production OS: macOS 15.3.1 (24D70, arm64)
Node version: 22.21.1
Package manager: yarn@1.22.22
Reka UI version: 2.9.6
Vue version: 3.5.32
CSS framework: tailwindcss@4.2.2
Client OS: macOS 15.3.1
Browser: Chrome 149.0.0.0Link to minimal reproduction
https://kolirt.github.io/reka-ui-dismissable-layer-body-pointer-events-repro/
Steps to reproduce
Live demo: https://kolirt.github.io/reka-ui-dismissable-layer-body-pointer-events-repro/
Source: https://github.com/kolirt/reka-ui-dismissable-layer-body-pointer-events-repro
Manual:
- Click Open popover (a modal
Popoverwhose content has a CSS exit animation; itsPopoverRootstays mounted — onlyopenflips tofalseon close). - Click Pick → close popover + open dialog — it closes the popover and opens a modal
Dialogin the same tick. - Wait ~half a second (until the popover's exit animation finishes) and click the amber button in the top bar.
The button behind the open modal dialog receives the click. The status panel shows document.body.style.pointerEvents live: it is none right after the handoff, then flips back to '' the moment the popover's exit animation ends — while the dialog is still open.
Automated: click Auto-run ×20 — the leak counter reaches 20/20 (fully deterministic).
Required ingredients (all three, see README):
- the closing popover's
PopoverRootstays mounted (onlyopenflips) and its content has a CSS exit animation, so itsDismissableLayerteardown is delayed; - a modal
Dialogmounts in the same tick the popover starts closing; - both layers are modal (
disableOutsidePointerEvents).
If the popover has no exit animation (or its whole root is unmounted via v-if), the teardown is synchronous and the bug does not occur.
Describe the bug
DismissableLayer coordinates modal outside-pointer blocking through a single module-level context: one shared originalBodyPointerEvents string plus the layersWithOutsidePointerEventsDisabled set, applied to document.body.style.pointerEvents.
When a modal layer B (Dialog) mounts while another modal layer A (Popover with a CSS exit animation) is still animating out, the body lock is silently lost at the end of A's animation:
- A opens — set
{A},originalBodyPointerEvents = ''saved, body →none. - B mounts while A is animating out — set size ≠ 0, so B only adds itself: set
{A, B}. Body staysnone. Correct so far. - A unmounts when its exit animation ends — A's
watchEffectcleanup seessize === 2, skips the restore; A is deleted from the set → set{B}. - The set-size change re-triggers B's own
watchEffect(the effect readslayersWithOutsidePointerEventsDisabled.size). Its cleanup runs first and now seessize === 1 && originalBodyPointerEvents != null→ restores body to''. The effect then re-runs, seessize !== 0, and never re-appliesnone.
Result: the modal dialog is still open, but document.body.style.pointerEvents is back to '' — everything behind the modal is clickable again.
Expected behavior
While at least one layer with disableOutsidePointerEvents is open, document.body.style.pointerEvents stays none. The original value is restored only when the last such layer unmounts. A modal layer that closes must never drop the body lock that another still-open modal layer relies on.
Context & Screenshots (if applicable)
No response
Activity
61021 commentedon Jul 31, 2026
Confirmed, and it's still live on current releases: your repro leaks 20/20 on 2.10.1 and on
v2HEAD, and 0/20 with the fix in #2832.One update to the mechanism for the record: the
watchEffectre-trigger path you traced matches ≤2.9.9 and was fixed by #2678 in 2.9.10. What keeps the symptom alive since then is a second writer —useBodyScrollLock'sresetBodyStyle()clearsbody.style.pointerEventsunconditionally when the last scroll-lock holder releases. In this composition that holder is the closing popover itself (PopoverContentModalkeeps its lock until the exit animation ends), while the dialog holds no scroll lock at all (that lives onDialogOverlay, which is optional and not rendered here) — so the popover's teardown wipes the body lock the dialog'sDismissableLayerstill owns. Full trace in #2832.Great repro, by the way — the deterministic auto-run made bisecting this across releases trivial.
fix(DismissableLayer): keep body pointer-events locked when the last …
fix(DismissableLayer): port v2 dismissal fixes and order layers from …
fix(v3): port missed v2 fixes and resolve regressions found in the v3…