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 3f38cf5dc1..f0c845afd5 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 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::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 == "ahb"), "every letter lands 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]