Skip to content

dialog: Animate the exit to match the entrance - #3603

Merged
huacnlee merged 3 commits into
longbridge:mainfrom
YidaWeng:fix/dialog-exit-animation
Oct 20, 2026
Merged

huacnlee merged 3 commits into
longbridge:mainfrom
YidaWeng:fix/dialog-exit-animation

Conversation

@YidaWeng

@YidaWeng YidaWeng commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3553

Description

DialogEntrance animated the dialog in, but close_dialog_internal removed it from the dialog stack in the same frame, so the surface, shadow, and backdrop cut away instead of leaving. Closing now keeps the dialog mounted until its exit transition finishes.

  • Closing reverses the surface motion: SlideDown returns to the top and FadeSlide reverses its travel, while the surface and dim fade out together. Fade fades at its final position.
  • A closing dialog is no longer active. It ignores Escape, backdrop presses, and confirm/cancel, and has_active_dialog only counts dialogs that are still open. Pointer input is released as soon as the close begins, so the application beneath is usable again; the popup keeps shielding its own surface until it unmounts.
  • The overlay belongs to the newest open dialog, falling back to the newest closing one so the dim fades instead of switching off. Closing the top of a stack keeps the dialog below mounted and hands the overlay back without a flash.
  • Exit state is keyed by a stable per-dialog id, so reopening during an exit starts a fresh entrance instead of inheriting the old one.
  • Reduced motion, DialogEntrance::None, and a zero theme duration still close in a single frame, preserving the previous synchronous contract. defer_close_dialog's focus restoration still compares open-dialog counts, so dialog: Preserve focus across menu actions and delayed restoration #3453's focus behavior is unchanged.

The base dialog host paints its popup in a deferred pass, where opacity applied to the layer no longer reaches it. The fade is therefore applied to the surface itself. That also makes the documented Fade/FadeSlide entrance fade visible, which the previous layer opacity never did; the entrance timing and motion are otherwise unchanged.

Screenshot

Not applicable: this is a time-based transition. The tests step the animation clock and assert the intermediate surface position, opacity, and unmount.

How to Test

  • Run the story gallery, open any Dialog, and close it with Escape or a button. The surface now slides or fades back out; with reduced motion enabled it disappears in one frame.
  • cargo test -p gpui-component --lib — 701 passed.
  • cargo test -p gpui-kit --test integration --features "test-support,component" — 402 passed.
  • cargo test -p gpui-shell --test integration — 121 passed.
  • cargo clippy -p gpui-component --all-targets -- -D warnings — clean. On the local nightly the pre-existing unnecessary_as_slice lint in searchable_list/vec.rs was allowed for this run; it is unrelated to this change.
  • cargo check -p gpui-component-story.

New tests cover the reverse trajectory and unmount, surface fading mid-exit, single-frame closing for reduced motion and zero durations, stacked retention, click-through to the app beneath, and reopening during an exit. Website docs are updated in English and Chinese.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

@YidaWeng
YidaWeng force-pushed the fix/dialog-exit-animation branch from 21ae0f0 to 197915c Compare October 19, 2026 13:20
@YidaWeng

Copy link
Copy Markdown
Contributor Author

CI note: the red Checks job is the typos check flagging the GitHub handles @UncertaintyDeterminesYou4ndMe and @alex-vas in release-notes.md from the v0.8.0 merge. It is unrelated to this PR. Build, the Linux/Windows test jobs, WebView, GPUI Fast on Ubuntu, and Shell Components have passed; macOS, Lint, and the remaining Fast/Shell jobs are still queued.

A closed dialog was removed in the same frame, so every DialogEntrance
played on the way in and vanished on the way out. Closing now retains the
dialog until a Presence transition sampled from the entrance state runs
back to zero, keyed by a stable per-dialog id.

A closing dialog accepts no Escape, backdrop press, confirm, or cancel,
stops counting as an active dialog, and releases pointer input: its dim
fades with the layer but no longer routes presses to the backdrop. The
overlay hands over to the next open dialog without a flash, stacked
dialogs keep the lower one mounted, and reopening during an exit gets a
fresh transition. Reduced motion, DialogEntrance::None, and a zero theme
duration still close in a single frame.

The base host paints its popup in a deferred pass, where opacity on the
layer no longer applies. The surface now carries the fade itself for the
exit and for the documented Fade/FadeSlide entrance.
@YidaWeng
YidaWeng force-pushed the fix/dialog-exit-animation branch from 197915c to 7a0e6bb Compare October 20, 2026 04:26
Share entrance and exit progress, retain stable dialog subtree identities, and block interaction with exiting content. Add interruption, reopening, and input regressions. AI-assisted implementation and regression tests.
@huacnlee
huacnlee enabled auto-merge (squash) October 20, 2026 13:18
huacnlee
huacnlee previously approved these changes Oct 20, 2026
Non-motion Kit tests relied on incidental entrance progress and the previous numeric surface ID. Use reduced motion and the stable surface ID while retaining every assertion. AI-assisted test updates, validated with the full Kit test suites on GPUI and GPUI Fast.
@huacnlee
huacnlee merged commit 41b6352 into longbridge:main Oct 20, 2026
19 checks passed
@YidaWeng
YidaWeng deleted the fix/dialog-exit-animation branch October 21, 2026 04:51
feigeCode added a commit to feigeCode/gpui-kit that referenced this pull request Oct 27, 2026
对话框层自 longbridge#3603 起带 Presence 进出场动画,render_dialog_layer 只能在
渲染期(prepaint/paint)调用。为宿主与测试提供只读查询函数
active_dialog_count(window, cx),返回活动对话框数(含退出动画中),
避免在非渲染期触碰渲染期 API。
madcodelife added a commit that referenced this pull request Nov 11, 2026
Closes #3752.

When a dialog is closed and another one is opened right away, the new
dialog appeared 16px lower during the old one's exit animation, then
jumped up when the exit ended.

Since #3603, a closing dialog stays in the stack until its exit
transition finishes. The stacking offset (`layer_ix * 16`), which also
reduces the available `max_height`, was computed from the dialog's index
in that stack, so it counted the dialog that was leaving.

## Changes
- `dialog_layer` now also counts the open (not closing) dialogs beneath
each dialog, and the offset and `max_height` use that count.
- `layer_ix` still holds the stack index for the debug selector and the
topmost check.

## Public API
None.

## Tests
`cargo test -p gpui-component --lib dialog`: 29 passed. The new
`a_closing_dialog_does_not_offset_the_next_one` checks that the second
dialog's bounds during the first one's exit equal its bounds after the
exit, both for a short body (offset) and a tall one (`max_height`). It
fails without the fix (y 96 vs 80).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dialog has an enter animation but no exit animation

2 participants