Repository navigation
fix: keep toasts mounted when a modal opens or closes - #1623
Merged
Merged
Conversation
The Toaster portaled into the topmost open dialog, and a portal that changes container remounts its children, so every toast disappeared and replayed its enter animation (and restarted its auto-close timer) each time a dialog opened or closed. Render the toasts into one stable host element and move that element between the body and the dialog instead. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When a modal dialog opened, the toast notifications on screen disappeared and animated back in; the same happened again when the modal closed. Their auto-close timers also restarted each time.
The
Toasterportaled its toasts into the overlay root:document.body, or the topmost open<dialog>so toasts stay above the modal and clickable. A portal that changes container unmounts and remounts its children, so every toast was remounted whenever a dialog opened or closed.Fix
The toasts now render into one stable host element, and that element is moved between the body and the dialog rather than re-portaled. It uses
moveBefore()where the browser supports it (which keeps running animations, focus and hover) and falls back toappendChild().Testing
🤖 Generated with Claude Code