junjizhi / junji-blog

My own blog
MIT License
0 stars 0 forks source link

Accessibility Comparison: listbox vs. menu #16

Open junjizhi opened 4 years ago

junjizhi commented 4 years ago

Why I write this post?

If you are fixing the accessibility (aka. a11y) issues of an existing site, and seeing a widget like below:

image

(Image source: https://ca.puma.com/)

Now answer this question: Which design pattern is this widget using?

Why is the question important? Because different widgets has different requirements on keyboard interactions, tag properties, states, etc.!

For example, you should be able to use the Space key to activate a dropdown if it is a menu, but there is no such key requirement for a listbox.

Another example: If a menu has submenu, your implementation should support left / right arrow keys to navigate to the submenus. Again, no such a thing for listboxes.

W3 ARIA site lists a handful of design patterns and widgets. But I was confused by these two particular ones: Listbox and Menu, because both of them can be implemented as a type of dropdown widget. So I decide to write a blog post to compare the two.

Which type of listboxes are we talking about?

Collapsable listboxes, like this one:

image

There are other types of listboxes, like scrollable listbox, where the options are listed in a flatten manner:

image

There are also multi-select listboxes:

image

You can see the difference easily between a dropdown and other types of listbox, so there's no need to talk them here.

Single Select Listboxes vs. Menus

The comparisons are mainly from the W3 ARIA site.

Differences Summary

From the above comparison, you can see that:

Going Back to the Beginning Question

Which widget is this?

image

To me, because it's in a menu bar and it's clear that it's for navigation purposes, so it is a menu.

That means, we are supposed to at least use Space key to activate the dropdown menu. Unfortunately, that doesn't work. Even a big brand like Puma doesn't get this right. 🤷‍♂️

We see such navigation menu bars in many ecommerce sites, such as Amazon, Sephora, Ebay. And none of the navigation bars support using the Space key to expand dropdowns.

To my surprise, Kijiji navigation bar actually has Space key support. Esc and arrow keys also work great. Kudos to Kijiji:

image

Obviously we have a lot of room to improve in terms of accessibility!

Disagree? Other thoughts? Drop me a comment below!