Aria-practices: Combobox with a Read Only Input

Created on 14 Feb 2020  路  7Comments  路  Source: w3c/aria-practices

There should be an option to have a combobox where a user can select an item, but not type in the input. This mimics the behavior of an HTML Select, but allows flexibility to style the listbox (currently, you cannot override the default HTML select styles).

Examples:

My main question is: How do we communicate that the user cannot type, but that they can select an option?

duplicate

Most helpful comment

I tested multiple variations of exactly this pattern last year in a usability study (and did straightforward AT support testing). I think we should implement this with role="combobox" on a <div> element, not an <input readonly>. I agree with @sinabahram about implementing typing to autoselect options.

More here, with sample implementations: https://www.24a11y.com/2019/select-your-poison-part-2/

All 7 comments

A quick note that even in default HTML selects, the user can still type, but just not as raw input, instead it鈥檚 treated as type-ahead search with a timeout that鈥檚 platform-specific, but feels right when it鈥檚 between 400MS and 800MS, IMHO, if only one letter is typed, it鈥檚 the same as first-letter navigation.

Such a construct should support the above.

Given that the default role of a select is Combobox, which aren鈥檛 read only, I鈥檝e always wondered why the role of Combobox on its own isn鈥檛 good enough as it entirely mimics the native control.

The aria-autocomplete property adds additional information needed to communicate you _can_ type into the field, so the lack of autocomplete should be fine as the default, with no read only property.

You can prevent the typing in the input with JavaScript, and hook into the event still to perform the behavior that @sinabahram mentions.

@SiTaggart But it feels weird to prevent users from typing in the input with JavaScript... But if this is the preferred pattern can an example be added to the ARIA Authoring Practices? Just so that the pattern is documented.

I tested multiple variations of exactly this pattern last year in a usability study (and did straightforward AT support testing). I think we should implement this with role="combobox" on a <div> element, not an <input readonly>. I agree with @sinabahram about implementing typing to autoselect options.

More here, with sample implementations: https://www.24a11y.com/2019/select-your-poison-part-2/

@smhigley commented:

I tested multiple variations of exactly this pattern last year in a usability study (and did straightforward AT support testing). I think we should implement this with role="combobox" on a <div> element, not an <input readonly>.

100% agree. We could also consider using a button instead of a div.

I agree with @sinabahram about implementing typing to autoselect options.

Mee too!

@carmacleod wrote:

Possible dup of #1026 ?

Yes, duplicate. Closing and will reference with a description of discussion.

Was this page helpful?
0 / 5 - 0 ratings