FontsPanel details sheet: a press outside closes it and reaches nothing below

This commit is contained in:
aiongg
2026-11-12 14:32:46 +00:00
parent 8f1a136e42
commit e4a8dfc2f8
2 changed files with 26 additions and 7 deletions
+15 -7
View File
@@ -11,6 +11,7 @@ use craft_behavior::ColumnWidth;
use craft_host::Host;
use craft_theme::variant::{Emphasis, Tone};
use craft_ui::buttons::Button;
use craft_ui::contract::overlay::Outside;
use craft_ui::contract::{Bind, CollectionEvent, NoValue, Outcome, Props as _, Show as _, ShowCollection as _, ShowContainer as _, clicked};
use craft_ui::dialog::Dialog;
use craft_ui::display::{Badge, Progress, Shade, Text};
@@ -206,7 +207,7 @@ struct Sheet {
pub(crate) struct DetailsOutput {
/// The dialog's response.
pub response: Response,
/// The sheet closed in this pass: Escape, its close action or a family that is gone.
/// The sheet closed in this pass: Escape, its close action, a press outside it or a family that is gone.
pub closed: bool,
}
@@ -218,7 +219,8 @@ impl Outcome for DetailsOutput {
}
}
/// The sheet of the family `panel.detail` names: a dialog on the modal preset, closed by Escape or its close action.
/// The sheet of the family `panel.detail` names: a dialog on the modal preset, closed by Escape, its close action or a
/// press outside it, which reaches nothing below.
#[derive(craft_ui::contract::Pattern, craft_ui::contract::Props)]
pub(crate) struct DetailsSheet<'a> {
panel: &'a mut FontsPanel,
@@ -244,12 +246,18 @@ impl<'a> DetailsSheet<'a> {
let points = panel.settings.size.max(MIN_SAMPLE_POINTS);
let mut todo: Vec<Do> = Vec::new();
let mut open = true;
let shown = Dialog::prompt(sheet.title.clone()).opened(Bind::bound(&mut open)).show(ui, |ui, _| {
Stack::new().show(ui, |ui, _| {
sheet.header(ui, &env, &words, &catalogs, &mut todo);
sheet.body(ui, &env, &words, &catalogs, points, &mut todo);
let shown = Dialog::prompt(sheet.title.clone())
.overlay(|overlay| {
let dismiss = overlay.dismiss.outside(Outside::Absorb);
overlay.dismiss(dismiss)
})
.opened(Bind::bound(&mut open))
.show(ui, |ui, _| {
Stack::new().show(ui, |ui, _| {
sheet.header(ui, &env, &words, &catalogs, &mut todo);
sheet.body(ui, &env, &words, &catalogs, points, &mut todo);
});
});
});
let closed = shown.output.closed.is_some();
if closed {
panel.detail = None;
+11
View File
@@ -236,3 +236,14 @@ fn find_puts_the_keyboard_in_the_search_field() {
let cards = rig.cards();
assert!(!cards.is_empty() && cards.iter().all(|name| !name.starts_with("Hack")), "the search keeps only Ubuntu: {cards:?}");
}
/// A press outside the details sheet closes it and reaches nothing below: the card under it does not open.
#[trial]
fn a_press_outside_the_details_sheet_closes_it() {
let mut rig = setup("outside");
let other = rig.fx.by_role(Role::LIST_ITEM).into_iter().last().expect("a second card");
rig.open("Hack");
rig.fx.click_at(Pos2::new(other.rect.left() + 4.0, other.rect.bottom() - 4.0));
rig.fx.settle();
assert_eq!(rig.panel.borrow().details_family(), None, "the sheet closed and no other family opened");
}