Coding is as much a matter of personal growth as it is of logic and control-flow. I keep patience, curiosity, & exuberance in the same toolbox as vim and git.
*Opinions posted are my own*
MDN has me telling anyone who will listen that non-interactive elements shouldn't have a tabindex. Are we just going to have to say that SPAs are an exception to the rule?
Usually that's correct--you should only give an element tabindex if a user can interact with it or provide it some input.
But for the specific case of managing focus I've often seen folks use this technique because there is no alternative way to move the users focus start point. Browsers actually have an internal API that they use to move the focus start point (developers.google.com/web/updates/...) but it's not exposed to developers as a JavaScript API. The tabindex + focus() trick I showed is a sort of near term hack to achieve a similar effect.
One of the things I really want to work on next is exposing the focus start point API so this trick becomes unnecessary.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey Rob thanks for the tip!
MDN has me telling anyone who will listen that non-interactive elements shouldn't have a
tabindex
. Are we just going to have to say that SPAs are an exception to the rule?Usually that's correct--you should only give an element tabindex if a user can interact with it or provide it some input.
But for the specific case of managing focus I've often seen folks use this technique because there is no alternative way to move the users focus start point. Browsers actually have an internal API that they use to move the focus start point (developers.google.com/web/updates/...) but it's not exposed to developers as a JavaScript API. The tabindex + focus() trick I showed is a sort of near term hack to achieve a similar effect.
One of the things I really want to work on next is exposing the focus start point API so this trick becomes unnecessary.