From 54a549100c20a16b1dfdd25d34042ece7d6c5838 Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 12 Nov 2026 01:57:57 +0000 Subject: [PATCH] CommandPalette: recents kept for the session when the host binds none --- .../src/patterns/panels/palette.rs | 23 ++++---- crates/ui-patterns/tests/it/panels/mod.rs | 1 + crates/ui-patterns/tests/it/panels/palette.rs | 58 +++++++++++++++++++ 3 files changed, 69 insertions(+), 13 deletions(-) create mode 100644 crates/ui-patterns/tests/it/panels/palette.rs diff --git a/crates/ui-patterns/src/patterns/panels/palette.rs b/crates/ui-patterns/src/patterns/panels/palette.rs index f08d4ed1e..733a190f3 100644 --- a/crates/ui-patterns/src/patterns/panels/palette.rs +++ b/crates/ui-patterns/src/patterns/panels/palette.rs @@ -69,8 +69,8 @@ impl crate::contract::Outcome for PaletteOutput { /// - Keys: the field keeps the focus; Up, Down, Page Up, Page Down move the active row (Up and Down wrap at the ends), /// Enter picks it, Escape clears /// the query and, on an empty query, closes the box; a press outside closes it. A caption under the list names the keys. The number of results is announced politely. -/// - Picking: the output's `picked` names the command and the box closes. With `recents` bound the command is also -/// put first in the list; [`CommandPalette::remember`] is the rule. +/// - Picking: the output's `picked` names the command, the box closes and the command goes first in `recents`; +/// [`CommandPalette::remember`] is the rule. Without a binding the palette keeps `recents` for the session. #[derive(Pattern, Props)] pub struct CommandPalette<'a> { label: Label, @@ -78,13 +78,13 @@ pub struct CommandPalette<'a> { open: Bind<'a, bool>, /// The commands last run, newest first. #[prop] - recents: Option>>, + recents: Bind<'a, Vec>, } impl<'a> CommandPalette<'a> { /// A palette named `label` over `entries`, open while `open` is true. pub fn new(label: impl Into