[yew-devel] [PATCH yew-widget-toolkit] widget: data table: don't fire extra selection change event

Dominik Csapak d.csapak at proxmox.com
Mon Dec 15 14:03:26 CET 2025


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 at 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





More information about the yew-devel mailing list