Your daily frequent11y newsletter, brought to you by @ChrisBAshton:
- Article by Eric Bailey, reminding developers to avoid manually specifying a tab order with
tabindex="[positive integer]"
(there is, arguably, never a good reason to do this). But usingtabindex="-1"
is great for building accessible widgets: it makes elements focusable with JavaScript or click/tap, where it would otherwise not be focusable (i.e. if it is not a link, a button or an input). - One of the hardest things to get right is “focus trapping“: restricting focus events so that they only apply to elements within your modal, so that keyboard users don’t get lost tabbing through invisible elements underneath. The
inert
attribute makes implementation a lot easier. Assuming your modal is in a<div>
outside of your<main>
, apply the attribute with<main inert>
and nothing within will be focusable. Browser support is extremely poor at the moment, but expect that to change in 2021. - I learned about a screen reader mode I hadn’t heard of: “interaction mode“. This allows users to explore the page with a ‘virtual cursor’, without applying focus to any of the content. Naturally that won’t play well with your modal, so liberal use of
aria-hidden="true"
is the answer.
Speaking of screen readers, the next issue of frequent11y will be a screen reader special – don’t miss it!
Prefer longer newsletters? You can subscribe to week11y, fortnight11y or even month11y updates! Every newsletter gets the same content; it is your choice to have short, regular emails or longer, less frequent ones. Curated with ♥ by developer @ChrisBAshton.