From 3208d26d8b6408eb6a604e956ffc5a4d0094ebfc Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 1 Dec 2026 00:09:09 +0100 Subject: [PATCH 1/2] menu: test that a typed letter a Help row marks lands in the Help search (photocraft#18548) Co-Authored-By: Claude Opus 5.5 --- crates/ui-widgets/tests/it/menu/pick_focus.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/ui-widgets/tests/it/menu/pick_focus.rs b/crates/ui-widgets/tests/it/menu/pick_focus.rs index 3f38cf5dc1..278017da2f 100644 --- a/crates/ui-widgets/tests/it/menu/pick_focus.rs +++ b/crates/ui-widgets/tests/it/menu/pick_focus.rs @@ -344,6 +344,23 @@ fn the_help_search_takes_its_editing_keys() { assert!(field_reads(&fixture, "txo"), "Left moves the caret before the last letter"); } +/// A letter typed as a keyboard sends it, a key press with its text, lands in the focused Help search, also a letter a +/// Help row marks: the field keeps the letter from About's A, and Help stays open. +#[trial] +fn a_typed_letter_a_help_row_marks_lands_in_the_help_search() { + let (mut fixture, count, _) = scoped_rig(); + let help = fixture.by_label("Help").expect("the Help title"); + fixture.click(&help); + fixture.settle(); + for (key, text) in [(egui::Key::A, "a"), (egui::Key::B, "b")] { + fixture.type_key(key, text); + fixture.settle(); + } + assert!(fixture.by_label("About").is_some(), "Help stays open"); + assert!(fixture.texts().iter().any(|run| run.text == "ab"), "both letters land in the search field"); + assert_eq!(count.get(), 0, "and run nothing"); +} + /// A command chord pressed after the focus moved between the rows of an open menu still runs in the scope focus came /// from and gives the focus back there, for a menu a title click opened and one F10 and Down opened. #[trial] From 873b8fd2a798c6a3f27daf842a82c0655abecf5b Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 1 Dec 2026 00:30:19 +0100 Subject: [PATCH 2/2] menu: a text field in a menu keeps its typing from the rows' mnemonic letters (photocraft#18548) Since 925810d52 the letters a menu level's rows mark are the level's claims while focus is anywhere in the level. That included Help's search field, so typing a letter a Help row marks ran the row and closed Help. The level's claims now hold only while focus is not on a text field. Co-Authored-By: Claude Opus 5.5 --- crates/ui-contract/src/runtime/keys/input.rs | 5 ++++- crates/ui-widgets/tests/it/menu/pick_focus.rs | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/ui-contract/src/runtime/keys/input.rs b/crates/ui-contract/src/runtime/keys/input.rs index 961302f0a2..08d84c0921 100644 --- a/crates/ui-contract/src/runtime/keys/input.rs +++ b/crates/ui-contract/src/runtime/keys/input.rs @@ -584,7 +584,10 @@ pub(super) fn focused_claims(record: &focus::FocusedRecord, stage: &Stage) -> Ve fn state_claims(record: &focus::FocusedRecord, stage: &Stage) -> Vec { let mut claims = Vec::new(); let canvas = record.canvas.filter(|_| !record.foreign); - let holds = |owner: Id| [record.focused, record.root, record.menu, record.menu_bar].contains(&Some(owner)); + // A text field in a menu (Help's search) keeps its typing: the letters the menu level claims for its rows' + // mnemonics hold only while focus is on a row. + let menu = record.menu.filter(|_| !record.keys.is_some_and(|keys| keys.owner == OwnerClass::Text)); + let holds = |owner: Id| [record.focused, record.root, menu, record.menu_bar].contains(&Some(owner)); // The unfocused canvas's tool never takes Tab or Shift+Tab: with nothing focused they move focus into the window, // so a tool that claims the plain keys cannot trap keyboard navigation. let canvas_holds = diff --git a/crates/ui-widgets/tests/it/menu/pick_focus.rs b/crates/ui-widgets/tests/it/menu/pick_focus.rs index 278017da2f..f0c845afd5 100644 --- a/crates/ui-widgets/tests/it/menu/pick_focus.rs +++ b/crates/ui-widgets/tests/it/menu/pick_focus.rs @@ -345,19 +345,19 @@ fn the_help_search_takes_its_editing_keys() { } /// A letter typed as a keyboard sends it, a key press with its text, lands in the focused Help search, also a letter a -/// Help row marks: the field keeps the letter from About's A, and Help stays open. +/// Help row or a bar title marks: the field keeps About's A and Help's H, and Help stays open. #[trial] fn a_typed_letter_a_help_row_marks_lands_in_the_help_search() { let (mut fixture, count, _) = scoped_rig(); let help = fixture.by_label("Help").expect("the Help title"); fixture.click(&help); fixture.settle(); - for (key, text) in [(egui::Key::A, "a"), (egui::Key::B, "b")] { + for (key, text) in [(egui::Key::A, "a"), (egui::Key::H, "h"), (egui::Key::B, "b")] { fixture.type_key(key, text); fixture.settle(); } assert!(fixture.by_label("About").is_some(), "Help stays open"); - assert!(fixture.texts().iter().any(|run| run.text == "ab"), "both letters land in the search field"); + assert!(fixture.texts().iter().any(|run| run.text == "ahb"), "every letter lands in the search field"); assert_eq!(count.get(), 0, "and run nothing"); }