You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[modal] feature: update to native <dialog> with showModal() - #154
The modal was using a <div role="dialog"> with a hand-rolled focus trap (sentinel elements + manual focus cycling). The native <dialog> element + showModal() handles focus trapping, top-layer stacking, and modal semantics natively — and is baseline-available in all modern browsers including Safari 15+.
Solution
Native <dialog>/showModal() replaces the manual focus trap; ModalInner and ModalBackdrop are removed.
Children render directly, centered in a dynamically sized viewport dialog. Native ::backdrop replaces the overlay, and backdrop clicks are handled internally.
Simplified close-button styling and hook transitions; dialogRef synchronizes native closing with state, URL hash, and focus restoration.
Additional Notes
Important
animate-presence animation support is not included in this refactor. Related examples and handling have been removed; follow-up work is tracked in #155.
@copilot update the description of this PR to include the updates we made since it was created. Also make an important note that animation with animate presence is currently not included in this refactor and also go ahead and remove the code and logic that handles that. we will address that in #155
@copilot update the description of this PR to include the updates we made since it was created. Also make an important note that animation with animate presence is currently not included in this refac...
Removed the animate-presence example, unused transition styles/dependency, and retained-dialog reopening logic in 23f2012. README now explicitly defers animation support to #155. Lint, TypeScript, build, browser checks, and CodeQL passed.
I couldn't edit the PR body with the available tools; GitHub browser access is blocked. Updated description summary:
Native <dialog>/showModal() replaces the manual focus trap; ModalInner and ModalBackdrop are removed.
Children render directly, centered in a dynamically sized viewport dialog. Native ::backdrop replaces the overlay, and backdrop clicks are handled internally.
Simplified close-button styling and hook transitions; dialogRef synchronizes native closing with state, URL hash, and focus restoration.
README and demos reflect the new API; a major changeset records the breaking changes.
Changing renderTo while Modal remains mounted recreates the portal's dialog element, but the ref object stays the same, so this effect does not run again. The replacement dialog stays closed and hidden while isOpen and any URL hash still indicate an open modal. Include renderTo in the dependencies so the replacement dialog receives showModal().
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Marlon U. Marcello <marlon.marcello@gmail.com>
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
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.
Description
The modal was using a
<div role="dialog">with a hand-rolled focus trap (sentinel elements + manual focus cycling). The native<dialog>element +showModal()handles focus trapping, top-layer stacking, and modal semantics natively — and is baseline-available in all modern browsers including Safari 15+.Solution
<dialog>/showModal()replaces the manual focus trap;ModalInnerandModalBackdropare removed.::backdropreplaces the overlay, and backdrop clicks are handled internally.dialogRefsynchronizes native closing with state, URL hash, and focus restoration.Additional Notes
Important
animate-presenceanimation support is not included in this refactor. Related examples and handling have been removed; follow-up work is tracked in #155.