Skip to content

fix(ui): enable dialog close animation#1102

Merged
perber merged 3 commits into
mainfrom
fix/dialog-close-animation
Jun 3, 2026
Merged

fix(ui): enable dialog close animation#1102
perber merged 3 commits into
mainfrom
fix/dialog-close-animation

Conversation

@perber

@perber perber commented Jun 2, 2026

Copy link
Copy Markdown
Owner

DialogManager was unmounting dialogs immediately when closeDialog() set dialogType to null in the store, so Radix UI Presence never had a chance to play the exit animation.

Keep the last active dialog in the React tree by only updating renderType and renderProps when a new dialog opens (dialogType !== null). BaseDialog derives open from the store directly, so it correctly gets open=false and Radix runs the fade-out before Presence unmounts the content.

Also add [animation-duration:200ms] to dialog and alert-dialog: in Tailwind v4 the duration-200 utility only sets transition-duration, while tailwindcss-animate defaults to 150ms for animation-duration.

DialogManager was unmounting dialogs immediately when closeDialog() set
dialogType to null in the store, so Radix UI Presence never had a chance
to play the exit animation.

Keep the last active dialog in the React tree by only updating renderType
and renderProps when a new dialog opens (dialogType !== null). BaseDialog
derives open from the store directly, so it correctly gets open=false and
Radix runs the fade-out before Presence unmounts the content.

Also add [animation-duration:200ms] to dialog and alert-dialog: in
Tailwind v4 the duration-200 utility only sets transition-duration, while
tailwindcss-animate defaults to 150ms for animation-duration.
Copilot AI review requested due to automatic review settings June 2, 2026 13:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes missing close (exit) animations for Radix UI dialogs by preventing dialogs from being immediately removed from the React tree when closeDialog() sets dialogType to null, and it aligns the dialog animation duration with the intended 200ms timing under Tailwind v4.

Changes:

  • Update DialogManager to keep rendering the last active dialog component while the store transitions dialogType to null, allowing Radix Presence to run exit animations.
  • Add an explicit [animation-duration:200ms] to dialog and alert-dialog content to ensure animation duration matches 200ms (since duration-200 only affects transition-duration in Tailwind v4).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
ui/leafwiki-ui/src/components/ui/dialog.tsx Adds explicit animation duration to ensure dialog enter/exit animation timing is 200ms.
ui/leafwiki-ui/src/components/ui/alert-dialog.tsx Adds explicit animation duration to ensure alert-dialog enter/exit animation timing is 200ms.
ui/leafwiki-ui/src/components/DialogManager.tsx Keeps the last dialog mounted after close to allow Radix Presence exit animations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/leafwiki-ui/src/components/DialogManager.tsx
perber added 2 commits June 2, 2026 15:47
Keeping the dialog mounted indefinitely would preserve local React state
(form inputs etc.) across close/reopen cycles. Use a 200ms timeout
matching the animation duration to unmount after Radix Presence has
finished the fade-out, restoring the original lifecycle semantics.
@perber
perber merged commit ab73e0d into main Jun 3, 2026
8 checks passed
@perber
perber deleted the fix/dialog-close-animation branch June 3, 2026 19:47
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.

2 participants