From 0f21da5c098d0a81102736da92febc343abcccf6 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Thu, 19 Nov 2026 17:28:21 +0000 Subject: [PATCH] fwstub-2: the in-place command palette names its search field by the palette's label, closed and open, not the generic words.palette_search (a title-bar search box keeps the app's name for it, S-L272); trial Co-Authored-By: Claude Opus 5.5 --- .../ui-patterns/src/patterns/panels/palette.rs | 7 ++++--- crates/ui-patterns/tests/it/panels/palette.rs | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/crates/ui-patterns/src/patterns/panels/palette.rs b/crates/ui-patterns/src/patterns/panels/palette.rs index 2334b2df5..e60ca671a 100644 --- a/crates/ui-patterns/src/patterns/panels/palette.rs +++ b/crates/ui-patterns/src/patterns/panels/palette.rs @@ -95,7 +95,8 @@ impl crate::contract::Outcome for PaletteOutput { /// runs, so its own modal layer blocks none. A disabled command is listed and does not run. /// - Faces: [`PaletteFace::Dialog`] is a centred modal box. [`PaletteFace::InPlace`] is a search box where it is laid /// out, showing the `placeholder`; it opens to the field with the key focus in the pass that opens it and lists the -/// results in a popup under the field. +/// results in a popup under the field. The in-place field is the palette's face, so it is named by the palette's +/// `label`, closed and open; the dialog face's field, inside a box named `label`, keeps the generic search name. /// - Empty query: with `suggested`, its heading and those commands; else the commands last run, newest first (the /// `recents` binding), else the first entries. /// - Fallback: with `fallback`, a last row follows the matches of a query, or stands alone when nothing matches. Picking @@ -227,7 +228,7 @@ impl<'a> CommandPalette<'a> { // The closed face is the search field's own look at its own size, so what sits beside it does not shift on open. let closed_face = !is_open && clicked( - &TextField::search(words.palette_search.clone(), Bind::given(String::new())) + &TextField::search(label.clone(), Bind::given(String::new())) .placeholder(face_hint.clone()) .id(field_id) .show(ui) @@ -252,7 +253,7 @@ impl<'a> CommandPalette<'a> { focus::request(&ctx, FocusTarget::Id(field_id)); } let session = inner.memory::(); - let field = TextField::search(words.palette_search.clone(), Bind::bound(&mut session.query)) + let field = TextField::search(label.clone(), Bind::bound(&mut session.query)) .placeholder(face_hint.clone()) .id(field_id) .show(ui) diff --git a/crates/ui-patterns/tests/it/panels/palette.rs b/crates/ui-patterns/tests/it/panels/palette.rs index 73fbdc50d..1e3f38a41 100644 --- a/crates/ui-patterns/tests/it/panels/palette.rs +++ b/crates/ui-patterns/tests/it/panels/palette.rs @@ -276,3 +276,19 @@ fn a_palette_opened_in_a_modal_dialog_lists_what_the_dialog_blocks_as_disabled() assert!(disabled(&fixture, "Rotate"), "the dialog under the palette blocks a default-rule app command"); assert!(!disabled(&fixture, "Zoom"), "a command that runs whatever is open stays enabled"); } + +/// The in-place face's field is the palette's face in the window (a title-bar search box), so a screen reader names it +/// by the palette's label, closed and open; the generic "Search commands" would drop the app's own name for it. +#[trial] +fn the_in_place_field_is_named_by_the_palettes_label_closed_and_open() { + let (mut fixture, open, ..) = faced(PaletteFace::InPlace, trial_entries(), None, None, false); + fixture.settle(); + for state in ["closed", "open"] { + let tree = fixture.tree(); + let names: Vec = + fixture.by_role(Role::TEXT_INPUT).iter().map(|field| tree.name_of(field.node).unwrap_or_default().to_owned()).collect(); + assert_eq!(names, vec!["Commands".to_owned()], "{state}: one search field, named by the palette's label"); + open.set(true); + fixture.settle(); + } +}