Skip to content

Comments

fix(morph): close dialogs properly when removing open attribute#4739

Merged
calebporzio merged 1 commit intomainfrom
fix/morph-dialog-close
Feb 7, 2026
Merged

fix(morph): close dialogs properly when removing open attribute#4739
calebporzio merged 1 commit intomainfrom
fix/morph-dialog-close

Conversation

@calebporzio
Copy link
Collaborator

Summary

  • Morphing a <dialog> that was opened via showModal() would call removeAttribute('open') directly. This hides the dialog visually but leaves it in the browser's top layer, making the entire page permanently inert (unclickable).
  • Now detects <dialog> elements and calls dialog.close() instead, which properly exits the top layer.

Changes

packages/morph/src/morph.js — In patchAttributes, when removing the open attribute from a <dialog>:

// Before
from.removeAttribute(name)

// After
if (name === 'open' && from.nodeName === 'DIALOG' && from.open) {
    from.close()
} else {
    from.removeAttribute(name)
}

tests/cypress/integration/plugins/morph.spec.js — Added test that opens a dialog via showModal(), morphs it closed, and verifies the page remains interactive.

Test plan

  • Existing morph tests pass (34/34)
  • New test: opens dialog with showModal(), morphs to remove open, asserts dialog is closed and page is not inert

🤖 Generated with Claude Code

Morphing a `<dialog>` opened via `showModal()` would call `removeAttribute('open')` directly, leaving the dialog in the browser's top layer and making the page permanently inert. Now calls `dialog.close()` instead, which properly exits the top layer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@calebporzio calebporzio merged commit f5dd340 into main Feb 7, 2026
2 checks passed
@calebporzio calebporzio deleted the fix/morph-dialog-close branch February 7, 2026 20:15
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