alphagov / accessible-autocomplete

An autocomplete component, built to be accessible.
https://alphagov.github.io/accessible-autocomplete/examples/
MIT License
916 stars 149 forks source link

Docs for autoselect are incorrect #466

Open edwardhorsford opened 4 years ago

edwardhorsford commented 4 years ago

The docs state that autoselect defaults to false - this does not appear to be the case at least for the accessibleAutocomplete.enhanceSelectElement() method is used - the feature is on by default.

This is problematic as autoselect is basically incompatible with show all values and causes usability issues.

matthewford commented 4 years ago

@edwardhorsford im writing a blog post on this atm with a fix in our branch

matthewford commented 4 years ago

Our branch https://github.com/alphagov/accessible-autocomplete/compare/master...bitzesty:select-behaviour

And a blog post on some of the changes we made. Once we rebase and update the docs we will raise a PR.

https://twitter.com/bitzesty/status/1309503796813484032

36degrees commented 2 years ago

It looks like the default value for autoselect is false: https://github.com/alphagov/accessible-autocomplete/blob/d617d5f0c60871ad9e0a3000ce8802edad749e92/src/autocomplete.js#L39

However, enhanceSelectElement specifically enables it (unless it's passed in as an option): https://github.com/alphagov/accessible-autocomplete/blob/d617d5f0c60871ad9e0a3000ce8802edad749e92/src/wrapper.js#L45

It currently says that it will do this in the README as well:

You can use the accessibleAutocomplete.enhanceSelectElement function to enhance it into an autocomplete:

accessibleAutocomplete.enhanceSelectElement({
  selectElement: document.querySelector('#location-picker')
})

This will:

  • Place an autocomplete input field after the specified <select>
  • Default the autocomplete autoselect to true
  • [...]

So I believe the docs are currently correct, even if the behaviour isn't desired.