Firefox 104 now supports the option.focusVisible
parameter for HTMLElement.focus()
. option.focusVisible can be used to force a browser to display a visible indicator when an element has programmatically been given focus. Without this being set, it is left up to the browser to determine if a visible focus indicator should be set or not.
Further reading:
- Bugzilla bug report: 1765083 - Focus Ring not always shown when focus is set in Javascript
- Chromium bug report (not implemented as of 2022.08.31): 1317039 - Focus Ring not always shown when focus is set in Javascript (implement FocusOptions.focusVisible)