Skip to content

Conversation

@Woozl
Copy link
Collaborator

@Woozl Woozl commented Feb 2, 2023

Here's a solution to the keyboard nav, it's not super Reacty though so I'm not loving it. It just shifts the focus +/-1 element based on the arrow key pressed. The browser then attempts to keep the focused element visible in the container by scrolling automatically.

react-window doesn't really provide an easy way to get the dom element of a list item based on its index, so this workaround looks at all of the list items in the current window to see if one of them matches the currently focused element. If it does, it takes the neighboring element in the array (+/-1 depending on direction) and sets the new focus to that.

@netlify
Copy link

netlify bot commented Feb 2, 2023

Deploy Preview for nb-search-portal failed.

Name Link
🔨 Latest commit 048cb4c
🔍 Latest deploy log https://app.netlify.com/sites/nb-search-portal/deploys/63e173b1ae0b65000838e95e

@mbwatson mbwatson marked this pull request as draft February 8, 2023 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants