diff --git a/crates/font-manager/src/panel/details.rs b/crates/font-manager/src/panel/details.rs index c94418bc4..c47105448 100644 --- a/crates/font-manager/src/panel/details.rs +++ b/crates/font-manager/src/panel/details.rs @@ -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 = 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; diff --git a/crates/font-manager/tests/it/panel.rs b/crates/font-manager/tests/it/panel.rs index c27b7137f..b3664dd02 100644 --- a/crates/font-manager/tests/it/panel.rs +++ b/crates/font-manager/tests/it/panel.rs @@ -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"); +}