Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set tabIndex -1 to implement Roving tabindex pattern #2046

Closed
steida opened this issue Jun 7, 2021 · 8 comments · Fixed by #2049
Closed

Allow to set tabIndex -1 to implement Roving tabindex pattern #2046

steida opened this issue Jun 7, 2021 · 8 comments · Fixed by #2049
Milestone

Comments

@steida
Copy link

steida commented Jun 7, 2021

Is your feature request related to a problem? Please describe.
Roving tabindex is the basic accessiblity pattern for grouped focusable items.

Describe a solution you'd like
RNfW should provide API for that so users don't have to hack it with setNativeProps in useEffect which can be too late.

Describe alternatives you've considered
There is no alternative for that.

Additional context
Here is an example https://codesandbox.io/s/gallant-germain-ujqnm?file=/src/App.js

@necolas
Copy link
Owner

necolas commented Jun 7, 2021

Show me how you can't already do this.

@necolas
Copy link
Owner

necolas commented Jun 7, 2021

This still works https://codesandbox.io/s/snowy-morning-fwke7

You only need tabIndex -1 if the element would otherwise natively receive focus.

@steida
Copy link
Author

steida commented Jun 7, 2021

  1. Try to click on any item. Nothing will happen because there is no tabIndex.
  2. More importantly, we have to track the current focus via onFocus which requires tabIndex -1

No, we can not set tabIndex 0 on all items. Then it would not be grouped.

Screenshot 2021-06-07 at 23 24 24

Screenshot 2021-06-07 at 23 27 25

@necolas
Copy link
Owner

necolas commented Jun 7, 2021

Try to click on any item

Add a press handler: https://codesandbox.io/s/snowy-morning-fwke7?file=/src/App.js

@necolas
Copy link
Owner

necolas commented Jun 7, 2021

We can make focusable=false explicitly set tabIndex=-1 though. I don't see the harm in that

@steida
Copy link
Author

steida commented Jun 8, 2021

Add a press handler

"Don't assume that all focus changes will come via key and mouse events."

From this document "https://developer.mozilla.org/en-US/docs/Web/Accessibility/Keyboard-navigable_JavaScript_widgets"

121089820-fcf1a600-c7e7-11eb-97bd-0215c618eb93

@steida
Copy link
Author

steida commented Jun 8, 2021

We can make focusable=false explicitly set tabIndex=-1 though. I don't see the harm in that

I agree. No focusable, no tabindex. Focusable true, tabindex 0. Focusable false, tabindex -1.
And for all elements, because everything can be focusable, as I described #2042

@steida
Copy link
Author

steida commented Jun 8, 2021

Thank you. After all those years (three), I can finally use The roving tabIndex pattern in RNfW without hacks.

#1099

rnike pushed a commit to VeryBuy/react-native-web that referenced this issue Sep 13, 2022
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 a pull request may close this issue.

2 participants