From: Dominik Csapak <d.csapak@proxmox.com>
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 [thread overview]
Message-ID: <20261016090256.1170172-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261016090256.1170172-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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<S: DataStore + 'static> Component for PwtDataTable<S> {
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
next prev parent 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 ` [PATCH yew-widget-toolkit 1/5] widget: data table: keep hidden columns when headers are recreated Dominik Csapak
2026-10-16 9:01 ` Dominik Csapak [this message]
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-3-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