From 935724850b99399bf18de81507f3513f56e21c5e Mon Sep 17 00:00:00 2001 From: MarekSpodBiedry <73122968+MarekSpodBiedry@users.noreply.github.com> Date: Sun, 18 Oct 2026 23:38:08 +0200 Subject: [PATCH] Insert: keep the Icons popup open when clicking the search box (#971) --- crates/ui-egui/src/icons_popup_tests.rs | 29 +++++++++++++++++++++++++ crates/ui-egui/src/ribbon.rs | 6 ++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/src/icons_popup_tests.rs diff --git a/crates/ui-egui/src/icons_popup_tests.rs b/crates/ui-egui/src/icons_popup_tests.rs new file mode 100644 index 00000000..63b5886e --- /dev/null +++ b/crates/ui-egui/src/icons_popup_tests.rs @@ -0,0 +1,29 @@ +//! Insert > Icons popup (#971): clicking inside it, e.g. in the "Search icons" box, must not close it. +#![allow(clippy::expect_used)] + +use deckcraft_engine::Session; +use egui_kittest::Harness; +use egui_kittest::kittest::Queryable; + +use crate::{Services, SlideApp}; + +#[test] +fn clicking_inside_the_icons_popup_keeps_it_open() { + let mut app = SlideApp::new(Session::with_new(), Services::default()); + app.ui.tab = "Insert".into(); + let mut h = Harness::builder().with_size(egui::vec2(1800.0, 900.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + app, + ); + h.run_steps(3); + h.get_by_label("Icons").click(); + h.run_steps(3); + // A category heading is plain popup content, like the search box: a click on it is a click inside. + let first = deckcraft_engine::icons::icons().first().expect("the icon gallery is empty"); + h.get_by_label(first.category).click(); + h.run_steps(3); + assert!(h.query_by_label(first.category).is_some(), "the icons popup closed after a click inside it"); +} diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs index 3a679dd1..74beb700 100644 --- a/crates/ui-egui/src/ribbon.rs +++ b/crates/ui-egui/src/ribbon.rs @@ -1249,7 +1249,7 @@ fn insert(app: &mut SlideApp, ui: &mut Ui) { } }); let r = big_button(ui, Icon::Icons, "Icons", enabled(app, "insert.icon")); - egui::Popup::menu(&r).width(340.0).show(|ui| icon_library(app, ui)); + egui::Popup::menu(&r).close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside).width(340.0).show(|ui| icon_library(app, ui)); big(app, ui, Icon::SmartArt, "SmartArt", "app.dialog", json!({"id": "smartart"})); let r = big_button(ui, Icon::Chart, "Chart", enabled(app, "insert.chart")); egui::Popup::menu(&r).show(|ui| { @@ -3474,6 +3474,10 @@ mod effects_tests; #[path = "master_layout_tests.rs"] mod master_layout_tests; +#[cfg(test)] +#[path = "icons_popup_tests.rs"] +mod icons_popup_tests; + #[cfg(test)] #[path = "align_tests.rs"] mod align_tests;