-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making progressive enhancement to selects behave more like a select #467
base: main
Are you sure you want to change the base?
Conversation
- Adding sensible defaults - Modifying the autoselect library to make keyboard interactions to support enhanced select dropdowns - Exposing a public API, with 1 function now to clear selection, which can be expanded to more functions later - Expanding tests to cover new functionality
@mauricioac would you be able to deploy somewhere so people can try this? |
Hi @edwardhorsford . Thanks for taking a look. I made a deployment on heroku: http://accessible-autocomplete-pr-467.herokuapp.com/examples/ |
@mauricioac I no longer work at GDS so can't help with getting this merged I'm afraid. But I'm interested for my own projects that might take advantage of it. Something I'm not clear of: is this new default behaviour, is it new behaviour for |
@edwardhorsford it would be a default behaviour regardless of The reationale was that showAllValues worked only when there was no previous selection. When the select had a previous selection, when opening the dropdown, only the selected value would show up. The problem of scoping under the existing |
@mauricioac I've had a play with it. I agree for the I may see if my team (DfE) can adopt your fork in places - assuming some of the below bugs get resolved. Some comments after playing with your version.
Since this is changing behaviour rather significantly, have you done any testing with assistive technologies? if so, what have you found? which technologies have you tested with? Sidebar: I think this is a case where we should also support |
I think it's because the second click is going to focus on the input, and that would filter out the results, which then reduces the list. Still need to think what should be done in this case and how it could be fixed.
I agree. Will get this one fixed
I did not test abandoning the select while typing before. Really interesting case though...
On our apps we did not use placeholder, so I did not test it. I'll try to see what this is about and if I can fix it.
I have tested with chromevox, since it's what I have on my linux machine. I did not spot any issues when I last tested the services. However, I noticed now that with the placeholder, the second time the dropdown is opened with keyboard arrows the focus goes to the first real option, the one after the placeholder. I'll take a look at this as well and see if I can fix this issue. I'm not sure if this is the behaviour you're describing as buggy. If yes, I totally agree. Because it really should be focusing on the placeholder, not the option after it. If this is not the case you're describing, could you please expand on it?
@edwardhorsford Thank you for giving this branch a test and finding these issues. I'm gonna see if I can reproduce and fix them. |
@mauricioac no problem. Having spent a lot of time working on this with @tvararu I remember how tricky it is. There's loads and loads of edge cases to think about. I'm motivated to help if I can though because I use I suspect for this to be merged by GDS (which I don't work for anymore) it would need significant testing in various AT. Possibly they could help with some of that - as each AT wouldn't take long. Chromevox is not commonly used by real users. When we first built and tested this component we found tonnes of inconsistency / issues we had to work around. In particular I expect this will need to do different things with focus, communicating that focus, and communicating what happens when the menu opens.
Normally we'd advise not having one - but I don't think it should break like this. What you're seeing is the hint overlaid on top, which should only happen when something is typed in and it matches / a result is selected but not confirmed. I suspect you've collapse the menu, but some bit of the autocomplete code still thinks it's open.
Another sidebar: I've never been happy with the inability to clear answers in the autocomplete. Possibly less relevant as selects can't be cleared either - but if it's emulating a select more closely then I think it would be good to explore an unset default state that you can return to. |
@edwardhorsford got a chance to work on the issues you mentioned. Unfortunately I did not mess around disabled options, as that would require changing the indexes used for tabbing, and when using lengths, as those would have to count the disabled ones, but not allow them to be selected. I did manage to fix a lot of the issues you mentioned, even a comment on your last response was a bug I fixed:
it was clearing to the I will see if I can get a VM up and running and install a bunch of ATs in it, and try to get someone to test using voice over on mac. Thanks for all the help so far in finding issues with my implementation. |
As @edwardhorsford points out, one of the issues when showing all after clicking when there's an existing selection is when do you go back into "filter" mode? When making any changes to the selected text? I also wonder whether the "currently selected" option needs some kind of visual indicator when showing all values? Currently it highlights in blue initially, but if you hover over any other option this indication disappears, even though the previous option is still selected. An alternative option to explore might be an enhanced select which behaves more like a regular select - ie always shows all options, but perhaps highlights matching ones instead. Another alternative option might be to, once an option has been selected, remove the autocomplete completely and just display the selected option in text, alongside a "change" button which re-reveals the autocomplete and resets it to blank, with a cancel option to return to the existing value. |
Is this still alive ? Maybe it would make sense to split this into separate PRs so things can be merged one by one ? |
Thanks for this, I have taken the fix for #240 from this (would be good if that could be extracted out to deal with that issue on its own). |
Take a fix from a wider PR alphagov/accessible-autocomplete#467 that fixes alphagov/accessible-autocomplete#240 so that after an option is chosen, opening the menu still shows all the values, rather than only the chosen option.
Well, if there is interest we can revive this; we still use it in the services we maintain. |
First of all, thank you all that helped develop this great library.
We, at Bit Zesty, maintain a couple of government services, specifically the GOV.UK Trade Tariff and the Queens Awards for Enterprise.
We were updating these apps to use the new Design System with the frontend library and had to replace the library we've been using; Select2.
We came across this library, but we weren't quite looking for an autocomplete library, but a select enhancement library. We saw it had some support, so we extended it so that the behaviour of keys and the overall behaviour matches the browser's native select.
In this PR, we propose merging back into mainstream the following changes:
(for all the items below, it's only when progressively enhancing a select):
Some of these changes also address issue #240
We also made a further change (which we are happy to make as a separate PR if needed) to enable programmatic control over the selection, specifically, we exposed a
clearSelection()
method so that we can easily clear the selection from a button in a simple way.This solves issue #334
We added a suite of tests to cover the changes and the programmatic control API.
Below I'm attaching some GIFs to more easily demonstrate the changes made.
I appreciate any feedback and happy to make changes if needed.
ps: on the left is the current behaviour, and on the right, is the updated.