accessible-autocomplete icon indicating copy to clipboard operation
accessible-autocomplete copied to clipboard

Input type="search" usage

Open AlecRust opened this issue 4 years ago • 1 comments

This is more of a question than anything since I assume there's a reason.

Why isn't type="search" used on the input field of this autocomplete?

This would:

  • Prevent Chrome's Autofill appearing, this seems one of the only ways to disable
  • Add a little "x" in some browsers to clear the search term
  • Clear the text when Esc was clicked

AlecRust avatar Nov 07 '19 12:11 AlecRust

Hi Alec,

Good question – thanks for getting in touch.

As you note, the accessible autocomplete is currently hardcoded to use an input of type="text". It's been that way since the start, and the original author is no longer actively involved with the project

https://github.com/alphagov/accessible-autocomplete/blob/0fcf3fd293b6473f174b38e045f6ec7cb93d36bd/src/components/typeahead/index.jsx#L11-L15

It might make sense to make this customisable, so that it can be set to type="search" in certain contexts. We use the component as an actual search interface in the GOV.UK Design System, for example – and it seems like it'd make sense there.

I'm not sure about making it type="search" by default, however. In most contexts (e.g. 'Select a country') the autocomplete is behaving more like an enhanced select box or a datalist than a search interface. I think if we were going to consider such a change we'd need to investigate:

  • how it'd be presented to assistive technologies – for example, if its role is affected, or if it appears as a search landmark, does this cause confusion to users?
  • how it'd affect e.g. the keyboard layout on tablet / mobile devices – for example, if the keyboard's action key then appears as 'search' does this cause confusion, as this may not align with the user's mental model of what they're trying to do.

Ollie

36degrees avatar Nov 18 '19 09:11 36degrees