From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 8DCDD1FF12D for ; Fri, 16 Oct 2026 11:03:00 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 3EAA2214F0; Fri, 16 Oct 2026 11:03:00 +0200 (CEST) From: Dominik Csapak 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 Message-ID: <20261016090256.1170172-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261016090256.1170172-1-d.csapak@proxmox.com> References: <20261016090256.1170172-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.359 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: MZG2IGS5BNYWAFCXTNGEZF6KEUPUGWE5 X-Message-ID-Hash: MZG2IGS5BNYWAFCXTNGEZF6KEUPUGWE5 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 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 --- 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 PwtDataTable { 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