all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
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	[thread overview]
Message-ID: <20260618080058.781054-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260618080058.781054-1-d.csapak@proxmox.com>

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 <d.csapak@proxmox.com>
---
 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





  parent reply	other threads:[~2026-06-18  8:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18  8:00 [PATCH yew-widget-toolkit/yew-widget-toolkit-assets 0/3] fix some field issues Dominik Csapak
2026-06-18  8:00 ` [PATCH yew-widget-toolkit-assets 1/3] utilities: generate a class for each element state opacity Dominik Csapak
2026-06-18 10:59   ` applied: " Dietmar Maurer
2026-06-18  8:00 ` [PATCH yew-widget-toolkit 2/3] widget: checkbox: make box-label adhere to disabled state Dominik Csapak
2026-06-18  8:00 ` Dominik Csapak [this message]
2026-06-18 11:07 ` applied: [PATCH yew-widget-toolkit/yew-widget-toolkit-assets 0/3] fix some field issues Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260618080058.781054-4-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=yew-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal