Skip to content

How to use Javascript to focus element which is set with useFocusRing. #3646

Answered by snowystinger
jeanpan asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jeanpan
Comment options

Answer selected by jeanpan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants