feat: add a close button to dialog

The close affordance reuses Button (ghost, small) at the panel's top
right and routes through on_change like escape and scrim clicks; it is
hidden in alert mode. The dialog feature now depends on button, and
AGENTS.md codifies preferring existing components over custom elements.
This commit is contained in:
2026-11-10 04:50:56 +07:00
parent ec906839ed
commit dc2c612cff
4 changed files with 63 additions and 7 deletions
+23
View File
@@ -158,3 +158,26 @@ fn clicking_the_panel_does_not_dismiss() {
click(&mut visual, point(px(960.), px(540.)));
assert!(changes.borrow().is_empty());
}
/// Clicking the close button reports close like escape and the scrim; the
/// panel then unmounts the button with the rest of the dialog.
#[test]
fn the_close_button_reports_close_and_disappears() {
let (_cx, mut visual, changes) = dialog_window(true, false);
let bounds = visual
.debug_bounds("dialog-close")
.expect("the close button rendered");
click(&mut visual, bounds.center());
assert_eq!(*changes.borrow(), vec![false]);
draw(&mut visual);
assert!(visual.debug_bounds("dialog-close").is_none());
}
/// An alert answers only through its actions, so it renders no close button.
#[test]
fn an_alert_hides_the_close_button() {
let (_cx, mut visual, _changes) = dialog_window(true, true);
assert!(visual.debug_bounds("dialog-close").is_none());
}