From 4f9d423a5cebd7befd1571f13fb62d12745b753c Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 4 Jan 2025 22:30:32 +0300 Subject: [PATCH] fix(item_list): enhance ItemsList component with centralized focus management for EditableCell - Added `focused_cell` and `set_focused_cell` signals to handle global focus state across cells. - Updated `EditableCell` usage in `ItemsList` to utilize `Arc` keys for efficient reference sharing. - Simplified focus handling by removing local state tracking and integrating centralized focus management. - Ensured better UX by making the currently edited cell regain focus after state updates. - Improved dynamic property handling by applying the new focus mechanism to both default and custom properties. --- src/components/items_list.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/components/items_list.rs b/src/components/items_list.rs index 3f9f2f6..df1cb6b 100644 --- a/src/components/items_list.rs +++ b/src/components/items_list.rs @@ -21,6 +21,9 @@ pub fn ItemsList( items: ReadSignal>, set_items: WriteSignal>, ) -> impl IntoView { + // State to track the currently focused cell + let (focused_cell, set_focused_cell) = create_signal(None::); + // State to manage dynamic property names let (custom_properties, set_custom_properties) = create_signal(Vec::::new()); @@ -159,8 +162,10 @@ pub fn ItemsList( "Name" => view! {
    {move || { @@ -199,15 +204,17 @@ pub fn ItemsList( "Description" => view! { }.into_view(), "Tags" => view! { }.into_view(), "Actions" => view! { @@ -240,7 +247,9 @@ pub fn ItemsList( }