public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [yew-devel] [PATCH yew-widget-toolkit] widget: data table: don't fire extra selection change event
Date: Mon, 15 Dec 2025 14:03:26 +0100	[thread overview]
Message-ID: <20251215130340.2411600-1-d.csapak@proxmox.com> (raw)

Instead of always clearing the selection and toggling the correct one,
directly select the correct one if the selection is not in multiselect
mode.

This prevents multiple selection change events when a user clicks a line
in the data table. (namely one from the clear, and one from the toggle)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/widget/data_table/data_table.rs | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/widget/data_table/data_table.rs b/src/widget/data_table/data_table.rs
index 7805340..1372a43 100644
--- a/src/widget/data_table/data_table.rs
+++ b/src/widget/data_table/data_table.rs
@@ -787,11 +787,16 @@ impl<S: DataStore> PwtDataTable<S> {
 
         self.last_select_position = Some(cursor);
 
-        if !(shift || ctrl) && props.multiselect_mode != MultiSelectMode::Simple {
-            selection.clear();
+        if selection.is_multiselect() {
+            if !(shift || ctrl) && props.multiselect_mode != MultiSelectMode::Simple {
+                selection.clear();
+            }
+
+            selection.toggle(record_key.clone());
+        } else {
+            selection.select(record_key.clone());
         }
 
-        selection.toggle(record_key.clone());
         true
     }
 
-- 
2.47.3



_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel


             reply	other threads:[~2025-12-15 13:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 13:03 Dominik Csapak [this message]
2025-12-16  8:41 ` [yew-devel] applied: " 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=20251215130340.2411600-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal