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: [PATCH yew-widget-toolkit 1/5] widget: data table: keep hidden columns when headers are recreated
Date: Fri, 16 Oct 2026 11:01:10 +0200	[thread overview]
Message-ID: <20261016090256.1170172-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261016090256.1170172-1-d.csapak@proxmox.com>

The data table resets the hidden state of all columns every time it
gets a new headers Rc, but the header widget keeps its state as long
as the column names don't change. Some callers create the headers in
their view function (e.g. the running tasks list in proxmox-yew-comp),
so the table gets a new Rc every time the parent renders.

This means that a column that was hidden via the header menu stays
hidden in the header, but is shown again in the rows, so the cells
don't match the header columns anymore.

To reproduce:
* use a data table where the parent creates the headers in its view
* hide a column via the header menu
* trigger a re-render of the parent, e.g. by changing its state

Fix this by using the same check as the header widget, and only reset
the hidden state when the column names change.

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

diff --git a/src/widget/data_table/data_table.rs b/src/widget/data_table/data_table.rs
index 9407844..b7a3941 100644
--- a/src/widget/data_table/data_table.rs
+++ b/src/widget/data_table/data_table.rs
@@ -1067,13 +1067,20 @@ impl<S: DataStore> PwtDataTable<S> {
         for header in props.headers.iter() {
             header.extract_column_list(&mut columns);
         }
-        let mut column_hidden = Vec::new();
-        for column in columns.iter() {
-            column_hidden.push(column.hidden);
+        // Like the header widget, keep the hidden state while the column names stay the same.
+        // Callers sometimes recreate the headers on every render, and resetting it here would show
+        // columns in the rows that the user hid in the header.
+        let same_columns = self.columns.len() == columns.len()
+            && self
+                .columns
+                .iter()
+                .zip(columns.iter())
+                .all(|(old, new)| old.name == new.name);
+        if !same_columns {
+            self.column_hidden = Rc::new(columns.iter().map(|column| column.hidden).collect());
         }
         self.headers = Rc::new(headers);
         self.columns = Rc::new(columns);
-        self.column_hidden = Rc::new(column_hidden);
     }
 }
 
-- 
2.47.3





  reply	other threads:[~2026-10-16  9:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  9:01 [PATCH yew-widget-toolkit 0/5] data table fixes Dominik Csapak
2026-10-16  9:01 ` Dominik Csapak [this message]
2026-10-16  9:01 ` [PATCH yew-widget-toolkit 2/5] widget: data table: update listeners when store or selection change Dominik Csapak
2026-10-16  9:01 ` [PATCH yew-widget-toolkit 3/5] widget: data table: update cell configuration on property change Dominik Csapak
2026-10-16  9:01 ` [PATCH yew-widget-toolkit 4/5] widget: data table: header: fix keyboard navigation from group headers Dominik Csapak
2026-10-16  9:01 ` [PATCH yew-widget-toolkit 5/5] widget: data table: header: skip hidden cells in keyboard navigation Dominik Csapak
2026-10-16  9:44 ` applied: [PATCH yew-widget-toolkit 0/5] data table fixes 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=20261016090256.1170172-2-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