From ec7b612c77c3cbc7ad855c104463cf0dca782848 Mon Sep 17 00:00:00 2001 From: rmsff <17902130+rmsff@users.noreply.github.com> Date: Mon, 9 Nov 2026 13:58:23 +0300 Subject: [PATCH] fix(ui): a mode list left open when a fill layer becomes active doesn't overwrite the stored choice (#12008) --- crates/ui-egui/src/panels/options_bar.rs | 2 ++ .../src/tools/gradient_mode_greyed_tests.rs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/crates/ui-egui/src/panels/options_bar.rs b/crates/ui-egui/src/panels/options_bar.rs index e6792c0c45..6cdf23e9e9 100644 --- a/crates/ui-egui/src/panels/options_bar.rs +++ b/crates/ui-egui/src/panels/options_bar.rs @@ -532,6 +532,8 @@ fn selection_specific_options(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: widgets::dropdown(ui, "gradient-mode", tl!("Mode"), &mut classic, &[(false, "Gradient"), (true, "Classic gradient")], 118.0) }) .inner + // A list opened before a fill layer became active can still be clicked. + && !fill { app.ui.tool_options.gradient_classic = classic; } diff --git a/crates/ui-egui/src/tools/gradient_mode_greyed_tests.rs b/crates/ui-egui/src/tools/gradient_mode_greyed_tests.rs index 565bcd8320..ce55fd98ce 100644 --- a/crates/ui-egui/src/tools/gradient_mode_greyed_tests.rs +++ b/crates/ui-egui/src/tools/gradient_mode_greyed_tests.rs @@ -164,3 +164,22 @@ fn hidden_and_locked_fill_layers_keep_the_choice() { assert_eq!(dropdown(&bar(app)), (false, "Classic gradient".into()), "{setup}"); } } + +/// A fill layer made active while the list is open, as a script or a layer shortcut can do: a +/// pick from the still-open list doesn't overwrite the stored choice. +#[test] +fn an_open_list_does_not_overwrite_the_choice_once_a_fill_layer_is_active() { + let (mut app, pixels, fill) = doc(); + app.ui.tool_options.gradient_classic = true; + select(&mut app, pixels); + let mut h = bar(app); + h.query_all_by_role(Role::ComboBox).find(|n| n.accesskit_node().value().as_deref() == Some("Classic gradient")).expect("the mode dropdown").click(); + h.run_steps(2); + select(h.state_mut(), fill); + h.run_steps(2); + assert_eq!(dropdown(&h), (true, "Gradient".into())); + let option = h.query_all_by_label("Gradient").find(|n| n.accesskit_node().role() != Role::ComboBox).expect("the list stays open"); + option.click(); + h.run_steps(2); + assert!(h.state().ui.tool_options.gradient_classic, "the stored Classic choice is kept"); +}