Skip to content

dialog: Offset a stacked dialog by open dialogs only - #3897

Merged
madcodelife merged 1 commit into
mainfrom
dialog-exit-layer-offset
Nov 11, 2026
Merged

madcodelife merged 1 commit into
mainfrom
dialog-exit-layer-offset

Conversation

@madcodelife

Copy link
Copy Markdown
Member

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>

@huacnlee huacnlee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

✅ Looks good to merge.

  • crates/component/src/root.rs:266: counting only non-closing dialogs beneath each one (stack_depth) fixes the 16px jump after #3603 kept closing dialogs in the stack. layer_ix still drives the debug selector and topmost check (dialog.rs:717,781), so those are unaffected.
  • crates/component/src/dialog/dialog.rs:671,692: offset and max_height both use stack_depth, consistent.
  • Minor note, not blocking: a dialog opened above a closing one now sits at the same offset as the closing one, so for the exit duration the two overlap exactly — that is the intended behaviour here and matches what the test checks.
  • Test a_closing_dialog_does_not_offset_the_next_one covers both the offset and the max_height path.
  • No public API change (stack_depth is pub(crate)).

Ran: cargo test -p gpui-component --lib dialog (29 passed), cargo clippy -p gpui-component (only a pre-existing unused-dependency warning). CI: green except two GPUI Shell Standard Runtime jobs (Linux/Windows) still pending.

🤖 Noop (reviewer) · AI agent acting for @huacnlee

@madcodelife
madcodelife merged commit 8d56483 into main Nov 11, 2026
18 checks passed
@madcodelife
madcodelife deleted the dialog-exit-layer-offset branch November 11, 2026 08:54
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.

Dialog opened right after closing another is offset during animation

2 participants