Skip to content

fix: remove windowless glass DOM when animate is false#113

Merged
ohxyz merged 1 commit into
mainfrom
fix/windowless-glass-remove-no-animate
Jun 30, 2026
Merged

fix: remove windowless glass DOM when animate is false#113
ohxyz merged 1 commit into
mainfrom
fix/windowless-glass-remove-no-animate

Conversation

@ohxyz

@ohxyz ohxyz commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Problem

removeWindowlessGlass(id, { animate: false }) short-circuited:

const detachedGlassEl = detachedGlassManager.removeDetachedGlass(id);
if (!animate) {
  return Promise.resolve(detachedGlassEl);
}

detachedGlassManager.removeDetachedGlass(id) only splices the glass out of the internal tracking array and returns the node — the actual glassEl.remove() (and modal backdrop removal) happens only inside removeDetachedGlassElement. So with animate: false, the glass shell (and any backdrop) was left orphaned on document.body.

This surfaced in react-bwin: when WindowProvider unmounts, its cleanup calls removeWindowlessGlass(id, { animate: false }) for each live glass. React tears down the content portal (inner content disappears) while bwin leaves the empty glass shell on screen.

Fix

Drop the early return and always delegate to removeDetachedGlassElement, which already removes the element + backdrop synchronously when animate is false. This matches the correct sibling removeDetachedGlass in crud.js.

Test plan

  • Open a windowless glass, then call removeWindowlessGlass(id, { animate: false }) — glass and any modal backdrop are removed from document.body.
  • In react-bwin, unmount the WindowProvider with a windowless glass open — no orphaned glass remains (dev/windowless-glass-unmount.tsx).

removeWindowlessGlass short-circuited on { animate: false }, splicing the
glass from the tracking array but never removing its DOM node or modal
backdrop, leaving them orphaned on document.body. Always delegate to
removeDetachedGlassElement, which removes synchronously when animate is
false — matching the sibling removeDetachedGlass.
@ohxyz ohxyz requested a review from bhjsdev as a code owner June 30, 2026 01:33
@ohxyz ohxyz merged commit 8c580c8 into main Jun 30, 2026
1 check passed
@ohxyz ohxyz deleted the fix/windowless-glass-remove-no-animate branch June 30, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant