mirror of
https://github.com/standardnotes/app.git
synced 2026-01-16 23:01:30 +00:00
refactor: list keyboard navigation
This commit is contained in:
parent
b07abaa5df
commit
28825bc2ee
1 changed files with 4 additions and 2 deletions
|
|
@ -23,7 +23,7 @@ export const useListKeyboardNavigation = (containerElement: HTMLElement | null,
|
|||
return
|
||||
}
|
||||
listItems.current = Array.from(containerElement.querySelectorAll('button, div[role="button"]'))
|
||||
if (listItems.current.length > 0) {
|
||||
if (listItems.current[0]) {
|
||||
listItems.current[0].tabIndex = 0
|
||||
}
|
||||
}, [containerElement])
|
||||
|
|
@ -73,7 +73,9 @@ export const useListKeyboardNavigation = (containerElement: HTMLElement | null,
|
|||
if (containerElement) {
|
||||
containerElement.tabIndex = FOCUSABLE_BUT_NOT_TABBABLE
|
||||
setLatestListItems()
|
||||
listItems.current[0].tabIndex = 0
|
||||
if (listItems.current[0]) {
|
||||
listItems.current[0].tabIndex = 0
|
||||
}
|
||||
}
|
||||
}, [containerElement, setLatestListItems])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue