From ce6e3a6a3a0b910f93ea908d50d77b2207a657fa Mon Sep 17 00:00:00 2001 From: Maccesch Date: Wed, 5 Jun 2024 09:45:46 +0200 Subject: [PATCH] add a create_effect to make sure external changes to the sorting signal are reflected in the table rendering. closes #40 --- src/components/table_content.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/table_content.rs b/src/components/table_content.rs index 7358eb4..76d37b7 100644 --- a/src/components/table_content.rs +++ b/src/components/table_content.rs @@ -232,6 +232,7 @@ where let load_row_count = load_row_count.clone(); move |clear_row_count: bool| { + logging::log!("clear"); selection.clear(); first_selected_index.set(None); @@ -247,22 +248,23 @@ where } } - set_reload_count.set(reload_count.get().overflowing_add(1).0); + set_reload_count.set(reload_count.get_untracked().overflowing_add(1).0); } }; - let on_head_click = { + let on_head_click = move |event: TableHeadEvent| { + sorting.update(move |sorting| sorting_mode.update_sorting_from_event(sorting, event)); + }; + + create_effect({ let rows = Rc::clone(&rows); let clear = clear.clone(); - move |event: TableHeadEvent| { - sorting.update(move |sorting| sorting_mode.update_sorting_from_event(sorting, event)); - + move |_| { rows.borrow_mut().set_sorting(&sorting.get()); - clear(false); } - }; + }); create_effect({ let rows = Rc::clone(&rows);