Open edwardhorsford opened 4 years ago
@edwardhorsford im writing a blog post on this atm with a fix in our branch
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.
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
totrue
- [...]
So I believe the docs are currently correct, even if the behaviour isn't desired.
The docs state that autoselect defaults to
false
- this does not appear to be the case at least for theaccessibleAutocomplete.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.