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 64E481FF13F for ; Thu, 18 Jun 2026 10:01:32 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 48FE2DC07; Thu, 18 Jun 2026 10:01:32 +0200 (CEST) From: Dominik Csapak To: yew-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 3/3] widget: input panel: correctly generate keys for custom children Date: Thu, 18 Jun 2026 10:00:46 +0200 Message-ID: <20260618080058.781054-4-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260618080058.781054-1-d.csapak@proxmox.com> References: <20260618080058.781054-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 Message-ID-Hash: LGT26F4RPGKVVUQJI5RLX6KU6CXGVTKO X-Message-ID-Hash: LGT26F4RPGKVVUQJI5RLX6KU6CXGVTKO 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: The input panel tries to extract a key from a custom child, but generates one if it can't. This generated key accidentally only included the `left_count` for its ID so two custom child (one on the left and one on the right in the same row) would get the same key, which leads to buggy and glitchy behavior (yews dom handling does not expect duplicate keys). Fix this by generating truly unique keys by including the row and column position, as well as the advanced state, like we do for normal fields. Signed-off-by: Dominik Csapak --- src/widget/input_panel.rs | 49 ++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/widget/input_panel.rs b/src/widget/input_panel.rs index 4c86bc4..d22049e 100644 --- a/src/widget/input_panel.rs +++ b/src/widget/input_panel.rs @@ -215,32 +215,33 @@ impl InputPanel { visible = false; } - let style = if visible { - let (row, start, span) = if self.mobile { - self.left_count += 1; // ignore position - (self.left_count, 1, -1) - } else { - match column { - FieldPosition::Left => { - self.left_count += 1; - (self.left_count, 1, 3) - } - FieldPosition::Right => { - self.two_column = true; - self.right_count += 1; - (self.right_count, 4, -1) - } - FieldPosition::Large => { - self.two_column = true; + let (row, start, span) = if self.mobile { + self.left_count += 1; // ignore position + (self.left_count, 1, -1) + } else { + match column { + FieldPosition::Left => { + self.left_count += 1; + (self.left_count, 1, 3) + } + FieldPosition::Right => { + self.two_column = true; + self.right_count += 1; + (self.right_count, 4, -1) + } + FieldPosition::Large => { + self.two_column = true; - let max = self.left_count.max(self.right_count); - self.left_count = max + 1; - self.right_count = max + 1; + let max = self.left_count.max(self.right_count); + self.left_count = max + 1; + self.right_count = max + 1; - (self.left_count, 1, -1) - } + (self.left_count, 1, -1) } - }; + } + }; + + let style = if visible { format!("grid-row: {}; grid-column: {}/{};", row, start, span) } else { "display: none;".to_string() @@ -251,7 +252,7 @@ impl InputPanel { None => { #[cfg(debug_assertions)] log::warn!("could not extract key from custom child, generating one"); - yew::virtual_dom::Key::from(format!("cl_{}", self.left_count)) + Key::from(format!("c_{}_{}_{}", start, row, advanced)) } }; -- 2.47.3