From f9c8af2032f77cf17af1642131dfcf875ae8d222 Mon Sep 17 00:00:00 2001 From: WofWca Date: Wed, 30 Oct 2024 14:41:59 +0400 Subject: [PATCH] WIP: refactor: `useRovingTabindex` to utilize IDs This should allow us to more easily `setActiveElement` by its ID, without having a reference to `HTMLElement`, e.g. we can more easily set the initial chat list item. This issue was mentioned in https://github.com/deltachat/deltachat-desktop/pull/4224: > The initially "active" element is just the first chat item, > and not the currently selected chat. --- .../src/components/chat/ChatListItem.tsx | 20 +- .../frontend/src/contexts/RovingTabindex.tsx | 172 +++++++++++++----- 2 files changed, 131 insertions(+), 61 deletions(-) diff --git a/packages/frontend/src/components/chat/ChatListItem.tsx b/packages/frontend/src/components/chat/ChatListItem.tsx index 23f37fb7f9..c5fe2a4279 100644 --- a/packages/frontend/src/components/chat/ChatListItem.tsx +++ b/packages/frontend/src/components/chat/ChatListItem.tsx @@ -174,17 +174,14 @@ function ChatListItemArchiveLink({ }, ]) - const ref = useRef(null) - const { tabIndex, onKeydown: tabindexOnKeydown, setAsActiveElement: tabindexSetAsActiveElement, - } = useRovingTabindex(ref) + } = useRovingTabindex() return (