How to use Javascript to focus element which is set with useFocusRing
.
#3646
-
As this example, I wonder if there is any way to set the focus on the button. Looks like using :focus pseudo class doesn't work either using javascript |
Beta Was this translation helpful? Give feedback.
Answered by
snowystinger
Oct 14, 2022
Replies: 1 comment 1 reply
-
If you check document.activeElement, it'll be the button. The reason focus isn't visible is because focus is still in the dev console. See https://codesandbox.io/s/objective-raman-yncg06?file=/src/App.js We show the focus ring only for keyboard users. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jeanpan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you check document.activeElement, it'll be the button. The reason focus isn't visible is because focus is still in the dev console.
See https://codesandbox.io/s/objective-raman-yncg06?file=/src/App.js
Keyboard navigate to the first button, then press Enter, second button will get focus and show the focus ring
We show the focus ring only for keyboard users.