mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 03:17:43 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
db60832d36
commit
0f21da5c09
@@ -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::<Session>();
|
||||
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)
|
||||
|
||||
@@ -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<String> =
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user