Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Fix panel-toggle shortcut test after modifier-aware capture (#7190).

nrq6993-a11y89522c585993
diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs
index b86c459f7..a2e426db0 100644
--- a/crates/ui-egui/src/prefs_ui.rs
+++ b/crates/ui-egui/src/prefs_ui.rs
@@ -911,10 +911,10 @@ fn capture_key_press(capture_mods: egui::Modifiers, i: &egui::InputState) -> (eg
pressed = Some((*key, mods | *modifiers));
break;
}
- if let egui::Event::Key { key, pressed: false, modifiers, .. } = e {
- if is_modifier_key(*key) {
- mods = *modifiers;
- }
+ if let egui::Event::Key { key, pressed: false, modifiers, .. } = e
+ && is_modifier_key(*key)
+ {
+ mods = *modifiers;
}
}
(mods, pressed)
diff --git a/crates/ui-egui/src/shortcut_capture_tests.rs b/crates/ui-egui/src/shortcut_capture_tests.rs
index f0dea8a78..769343e78 100644
--- a/crates/ui-egui/src/shortcut_capture_tests.rs
+++ b/crates/ui-egui/src/shortcut_capture_tests.rs
@@ -215,7 +215,13 @@ fn a_function_key_moved_off_a_panel_toggle_runs_its_new_command() {
// row in the dialog is Photoshop's `window.panel.brushSettings` while the key ran the shell's
// `window.toggle.brushSettings`.
let (mut h, id) = dialog(1.0, "select.modify.feather", "feather");
- capture(&mut h, &crate::shortcuts::pretty("Shift+F6"), Key::ShiftLeft, Modifiers::NONE, Key::F5);
+ // Enter capture on the default row, then press plain F5 (not Shift+F5: #7190 records held modifiers).
+ h.get_by_label(&crate::shortcuts::pretty("Shift+F6")).click();
+ h.run_steps(2);
+ key(&mut h, Key::F5, true, Modifiers::NONE);
+ h.run_steps(1);
+ key(&mut h, Key::F5, false, Modifiers::NONE);
+ h.run_steps(2);
let message = field(&h, id, "message");
assert!(message.as_str().unwrap().contains("already in use"), "{message}");
crate::dialogs::confirm(h.state_mut(), id).unwrap();