Repository navigation
dialog: Support configurable entrance animations - #3405
Merged
Merged
Conversation
huacnlee
enabled auto-merge (squash)
October 8, 2026 06:10
linruohan
pushed a commit
to linruohan/gpui-component
that referenced
this pull request
Oct 9, 2026
## Description
Dialogs always slide from the window top to their resting position while
fading in. When a dialog rests low in a tall window, it crosses much of
the window before settling.
Add a shared `DialogEntrance` API so applications can choose the
entrance for both `Dialog` and `AlertDialog`:
```rust
dialog.entrance(DialogEntrance::FadeSlide)
alert.entrance(DialogEntrance::Fade)
```
| Entrance | Behavior |
| --- | --- |
| `SlideDown` (default) | Existing slide from the window top with its
original timing and easing. |
| `Fade` | Fade in at the final position without movement. |
| `FadeSlide` | Fade in with short downward travel from above the
resolved resting position. |
| `None` | Display the surface and backdrop immediately. |
`Fade` and `FadeSlide` use the theme's normal duration and enter easing.
`FadeSlide` uses the theme's short motion distance and applies travel
after window-boundary positioning, so a dialog clamped upwards still
moves relative to its actual resting position. Travel is shortened when
there is insufficient space above the surface, and pointer hit testing
follows the moving surface.
Reduced motion immediately displays the final state for every option. A
zero theme duration also skips the fade entrances. Surface opacity,
shadows, and the backdrop use the same entrance timing. Closing remains
immediate.
The Dialog story exposes all four choices under Options → Entrance.
Dialog and AlertDialog documentation is updated in English and Chinese.
## Public API
### gpui-component
- `#[non_exhaustive] pub enum dialog::DialogEntrance { SlideDown, Fade,
FadeSlide, None }` — Select the shared entrance presentation. Implements
`Clone`, `Copy`, `Debug`, `Default`, `PartialEq`, `Eq`, `Serialize`, and
`Deserialize`.
- `DialogEntrance::SlideDown` — Default; preserve the existing slide and
fade entrance.
- `DialogEntrance::Fade` — Fade at the final position without movement.
- `DialogEntrance::FadeSlide` — Fade with bounded, theme-defined
downward travel.
- `DialogEntrance::None` — Immediately show the surface and backdrop.
- `Dialog::entrance(self, entrance: DialogEntrance) -> Self` — Choose
the dialog entrance.
- `AlertDialog::entrance(self, entrance: DialogEntrance) -> Self` —
Apply the same entrance policy to an alert dialog.
## Breaking Changes
None for existing consumers. The API is additive and `SlideDown`
preserves the existing default behavior.
## Validation
- `cargo test -p gpui-component --lib dialog -- --nocapture` — 17
passed, covering resolved-boundary travel, intermediate positions,
top-edge limits, pointer hit testing, builder defaults, AlertDialog
forwarding, reduced motion, immediate keyboard dismissal, and zero theme
duration.
- `cargo check -p gpui-component-story` — passed.
- `cargo clippy -p gpui-component -p gpui-component-story --all-targets
-- --deny warnings` — passed.
- `cargo fmt --all --check` and `git diff --check` — passed.
Implementation, tests, and documentation were generated with AI
assistance. The story was compile-checked; its animations were not
manually compared across platforms.
---------
Co-authored-by: xxww0098 <shefkie1957@gmail.com>
Co-authored-by: Jason Lee <huacnlee@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
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.
Description
Dialogs always slide from the window top to their resting position while fading in. When a dialog rests low in a tall window, it crosses much of the window before settling.
Add a shared
DialogEntranceAPI so applications can choose the entrance for bothDialogandAlertDialog:SlideDown(default)FadeFadeSlideNoneFadeandFadeSlideuse the theme's normal duration and enter easing.FadeSlideuses the theme's short motion distance and applies travel after window-boundary positioning, so a dialog clamped upwards still moves relative to its actual resting position. Travel is shortened when there is insufficient space above the surface, and pointer hit testing follows the moving surface.Reduced motion immediately displays the final state for every option. A zero theme duration also skips the fade entrances. Surface opacity, shadows, and the backdrop use the same entrance timing. Closing remains immediate.
The Dialog story exposes all four choices under Options → Entrance. Dialog and AlertDialog documentation is updated in English and Chinese.
Public API
gpui-component
#[non_exhaustive] pub enum dialog::DialogEntrance { SlideDown, Fade, FadeSlide, None }— Select the shared entrance presentation. ImplementsClone,Copy,Debug,Default,PartialEq,Eq,Serialize, andDeserialize.DialogEntrance::SlideDown— Default; preserve the existing slide and fade entrance.DialogEntrance::Fade— Fade at the final position without movement.DialogEntrance::FadeSlide— Fade with bounded, theme-defined downward travel.DialogEntrance::None— Immediately show the surface and backdrop.Dialog::entrance(self, entrance: DialogEntrance) -> Self— Choose the dialog entrance.AlertDialog::entrance(self, entrance: DialogEntrance) -> Self— Apply the same entrance policy to an alert dialog.Breaking Changes
None for existing consumers. The API is additive and
SlideDownpreserves the existing default behavior.Validation
cargo test -p gpui-component --lib dialog -- --nocapture— 17 passed, covering resolved-boundary travel, intermediate positions, top-edge limits, pointer hit testing, builder defaults, AlertDialog forwarding, reduced motion, immediate keyboard dismissal, and zero theme duration.cargo check -p gpui-component-story— passed.cargo clippy -p gpui-component -p gpui-component-story --all-targets -- --deny warnings— passed.cargo fmt --all --checkandgit diff --check— passed.Implementation, tests, and documentation were generated with AI assistance. The story was compile-checked; its animations were not manually compared across platforms.