From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 69D271FF129 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 1AF7A21470; Fri, 16 Oct 2026 11:03:00 +0200 (CEST) From: Dominik Csapak To: yew-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 2/5] widget: data table: update listeners when store or selection change Date: Fri, 16 Oct 2026 11:01:11 +0200 Message-ID: <20261016090256.1170172-3-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.361 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: FDUALY62R3UACUXIBX56C2S6W7KIXCJU X-Message-ID-Hash: FDUALY62R3UACUXIBX56C2S6W7KIXCJU 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 listeners for the store and the selection are only registered when the table is created. If the parent passes a different store or selection later, the table still listens to the old ones, so changes to the new store or selection don't update the table until something else triggers a render. To reproduce: * render a data table with a store * re-render the parent with a new store * change the data of the new store, e.g. with 'set_data' The table still shows the data the new store had when it was passed in. Fix this by registering the listeners again when the store or the selection changes, like we already do in the SelectionView, and update the selection status for a new selection. Signed-off-by: Dominik Csapak --- src/widget/data_table/data_table.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/widget/data_table/data_table.rs b/src/widget/data_table/data_table.rs index b7a3941..6a30dc2 100644 --- a/src/widget/data_table/data_table.rs +++ b/src/widget/data_table/data_table.rs @@ -1813,10 +1813,19 @@ impl Component for PwtDataTable { let props = ctx.props(); if props.store != old_props.store { - // store changed + self._store_observer = props + .store + .add_listener(ctx.link().callback(|_| Msg::DataChange)); self.update_scroll_info(props); } + if props.selection != old_props.selection { + self._selection_observer = props.selection.as_ref().map(|selection| { + selection.add_listener(ctx.link().callback(|_| Msg::SelectionChange)) + }); + self.update_selection_status(props); + } + if props.headers != old_props.headers { self.init_headers(props); } -- 2.47.3