From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 56A281FF13F for ; Thu, 18 Jun 2026 16:44:30 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EC8581B17A; Thu, 18 Jun 2026 16:44:29 +0200 (CEST) From: Dominik Csapak To: yew-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 2/2] widget: selector: don't autoselect or set to default more than once Date: Thu, 18 Jun 2026 16:44:18 +0200 Message-ID: <20260618144425.3901589-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260618144425.3901589-1-d.csapak@proxmox.com> References: <20260618144425.3901589-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.049 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [selector.rs] Message-ID-Hash: QI7RFH5N6AUZR4KCSAIRCMXTXQVCMUVJ X-Message-ID-Hash: QI7RFH5N6AUZR4KCSAIRCMXTXQVCMUVJ X-MailFrom: d.csapak@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: Autoselect or setting the default should only happen once, otherwise clearing e.g. a combobox and trying to open the picker (which sets a filter+sorter, which triggers a DataChange event) sets it back to the default instead of opening it. Signed-off-by: Dominik Csapak --- src/widget/form/selector.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/widget/form/selector.rs b/src/widget/form/selector.rs index 018d34f..1878a89 100644 --- a/src/widget/form/selector.rs +++ b/src/widget/form/selector.rs @@ -165,6 +165,7 @@ pub enum Msg { pub struct SelectorField { state: ManagedFieldState, selection: Selection, + value_set: bool, load_error: Option, _store_observer: S::Observer, abort_load_guard: Option, @@ -278,6 +279,7 @@ impl ManagedField for SelectorField { let mut me = Self { state: ManagedFieldState::new(value, default), selection, + value_set: false, load_error: None, _store_observer, abort_load_guard: None, @@ -329,7 +331,7 @@ impl ManagedField for SelectorField { Msg::DataChange => { let value = self.value.as_str().unwrap_or("").to_owned(); - if self.load_error.is_none() && value.is_empty() { + if self.load_error.is_none() && value.is_empty() && !self.value_set { let mut default = props.default.clone(); if default.is_none() && props.autoselect { @@ -341,6 +343,7 @@ impl ManagedField for SelectorField { if let Some(default) = default { ctx.link().update_value(default.to_string()); ctx.link().update_default(default.to_string()); + self.value_set = true; } } ctx.link().validate(); // re-evaluate -- 2.47.3