From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 5A29C1FF13C for ; Thu, 05 Mar 2026 12:21:30 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DFCAD61CE; Thu, 5 Mar 2026 12:22:35 +0100 (CET) From: Shannon Sterz To: yew-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 1/1] gridpicker/combobox: allow autoselecting the filter field Date: Thu, 5 Mar 2026 12:21:58 +0100 Message-ID: <20260305112158.220557-5-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260305112158.220557-1-s.sterz@proxmox.com> References: <20260305112158.220557-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1772709695073 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.096 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: XFGCQ5OR7O32MVCPQGJKSOZO6NC2M5TX X-Message-ID-Hash: XFGCQ5OR7O32MVCPQGJKSOZO6NC2M5TX X-MailFrom: s.sterz@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Yew framework devel list at Proxmox List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Shannon Sterz --- src/widget/form/combobox.rs | 8 ++++++++ src/widget/grid_picker.rs | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/widget/form/combobox.rs b/src/widget/form/combobox.rs index db4505f6..efc2365f 100644 --- a/src/widget/form/combobox.rs +++ b/src/widget/form/combobox.rs @@ -99,6 +99,11 @@ pub struct Combobox { #[prop_or_default] #[builder] pub trigger: Vec<(Trigger, bool)>, + + /// Whether the filter should be auto-selected when the picker is displayed. + #[builder(IntoPropValue, into_prop_value)] + #[prop_or_default] + pub autoselect_filter: Option, } impl Default for Combobox { @@ -295,6 +300,8 @@ impl Component for PwtCombobox { .show_filter .unwrap_or_else(|| self.store.data_len() > 10); + let auto_select_filter = ctx.props().autoselect_filter; + let filter = props.filter.clone(); let columns = Rc::clone(&self.columns); @@ -311,6 +318,7 @@ impl Component for PwtCombobox { .selection(args.selection.clone()) .show_filter(show_filter) .filter(filter.clone()) + .autoselect_filter(auto_select_filter) .on_select(args.controller.on_select_callback()); if show_filter { diff --git a/src/widget/grid_picker.rs b/src/widget/grid_picker.rs index 5e8d44d0..304e54a2 100644 --- a/src/widget/grid_picker.rs +++ b/src/widget/grid_picker.rs @@ -74,6 +74,11 @@ pub struct GridPicker { #[builder_cb(IntoTextFilterFn, into_text_filter_fn, S::Record)] #[prop_or_default] pub filter: Option>, + + /// Whether the filter should be auto-selected when the picker is displayed. + #[builder(IntoPropValue, into_prop_value)] + #[prop_or_default] + pub autoselect_filter: Option, } impl GridPicker { @@ -196,6 +201,7 @@ impl Component for PwtGridPicker { .with_child(html! {}) .with_child( Input::new() + .autofocus(ctx.props().autoselect_filter.unwrap_or_default()) .attribute("autocomplete", "off") .attribute("size", "1") // make size minimal .class("pwt-input") -- 2.47.3