ScottLogic / blog

The Scott Logic blog
http://blog.scottlogic.com
Other
9 stars 86 forks source link

Provide an accessible label for the combobox in the compact category list #141

Closed jcarstairs-scottlogic closed 10 months ago

jcarstairs-scottlogic commented 10 months ago

When you view the homepage or a Category page with a sufficiently narrow screen, you get a combo box to choose a different category page to go to.

A screenshot of the combo box on the current live blog

This combobox doesn't have an accessible label. NVDA + Firefox currently announce the combobox as:

clickable combo box Latest Articles collapsed

I've reworded 'Categories' to 'Category', on the grounds that the user should choose a single 'category' not multiple 'categories'. And I've re-marked-upped it from a <h3> to a <label> which is explicitly associated with the combo box using the for attribute. I've also sprinkled in a bit of CSS so that the visual appearance is almost identical. Here's what it looks like:

A screenshot of the combobox after this PR

The top margin is subtly different, but I think there's no obvious need for that subtly different top margin that would justify an extra line of CSS. Happy to be overruled if you disagree!

Now, the combo box is announced by NVDA + Firefox as:

Category combo box Latest Articles collapsed

This should be generally in line with user expectations. Compare, for example, this location combo box from the footer in the BBC iPlayer website:

A screenshot of the location combo box from the footer in the BBC iPlayer website

This is read out as:

Change location combo box East Yorks & Lincs collapsed

This clears two errors identified by pa11y. Here's a screenshot where I run pa11y on the live blog and get two errors, but when I run the same pa11y command on my localhost version of the blog running on this branch, the errors go away.

Screenshot of pa11y finding two errors with the live blog which are resolved with this PR