-
Notifications
You must be signed in to change notification settings - Fork 411
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
Fix SingleChoiceInput accessibility issues #6310
base: master
Are you sure you want to change the base?
Conversation
foxbunny
commented
Apr 23, 2024
- Replace SUI's Dropdown compoennt with a custom Combobox component
- Implement a custom element used by Combobox
- Add useNativeEvent hook
- Tweak regform styles to handle the new controls
5cfc830
to
f3f5da5
Compare
Hi @foxbunny, could you please explain in more detail what accessibility issues you're trying to solve here? I think you meant usability. There is still an issue when the user types in an entry that is not part of the drop-down options; there is no feedback that this entry is not valid and will not be sent (Given that the field is not required). And even if the field is required, the feedback gotten is "This field is required", which can be confusing since the user might think the field input has been provided, but in reality the input is not valid. |
The primary accessibility issues that are being solved is incompatibility of the SUI combobox with screen readers. In particular, not announcing the options, not being clear about what effect the typing has, etc.
I've already pointed this out to @ThiefMaster. It's a validation issue, not really an accessibility issue. |
Thanks for the PR!
Can we do something about it in this PR? Here's just some small styling issues I noticed: When expanded I'd disable the bottom border radius on the input field: I'd align the options with the text input as it was before (i.e. increase left padding for the options) The list needs a higher z-index: From a usability point of view, I noticed that if I have two options, one uppercase and one lowercase e.g. |
My understanding was that it wasn't something we can do, but I can check the code, sure.
Gotcha. Thanks.
Hmmm. I'm not sure we should support this case at all. See, for screenreaders, there's absolutely no difference between capital A and lowercase a. So even if I make the combobox do case-sensitive matching in case of conflicts, it won't help screenreader users one bit. |
I can imagine regular users not being happy with the combobox changing their input.. If it doesn't hurt screenreader users I'd prefer case-sensitive matching |
Do you really intend to have options that are identical except for the case? If you ask me, I'd forbid that during form creation. |
Anyway, back to the discussion on case-matching. Suppose we have the following items in the list:
The most trivial thing we can do is match at the start of the string case-sensitively. For example, if we type "A", it matches "ACME". If we type "Ac", it matches "Acme" and not "ACME". This has some edge cases. For example, if we type "acM" it will match "ACME" and not "acme" or "aCme" even though the first character is lower-case. How elaborate do you want this algorithm to be? For example, we could count the number of characters that match by position and case. Or we could count the longest perfectly matching consecutive characters. Etc. |
A more radical idea, but what if we just don't autocomplete? As in, we keep the behaviour of the current dropdown? On an unrelated note:
|
I deliberately avoided using that approach because it causes usability issues such as matching something that isn't obviously what the user started off to type. (For instance in the country selector you start to type "Ser" it will give you "Montserrat" as the first option.) But anyway, I leave that up to you.
Sure, we can add that. |
Updated the PR. Fix styling issues, and implemented two strategies for handling typing based on the |
- Replace SUI's Dropdown compoennt with a custom Combobox component - Implement a custom <ind-combobox> element used by Combobox - Add useNativeEvent hook - Tweak regform styles to handle the new controls
- Fix styling glitches - Add support for optional clear button - Add clear button to Combobox - Add support for toggling autocomplete using aria-autocomplete - Disable autocomplete in Combobox (can be toggled back on as needed)
Rebased on master, and also fixed the validation logic so it correctly traps invalid choices. |
@tomasr8 Reminder, just in case. |
I noticed some differences from the old dropdown. Some of these might be nice to keep for the new one as well:
I'd also increase the height of the listbox a bit, currently it feels a bit too small |
Do we even need the amount drop-down to be a combobox? I can replace it with a plain select list. |
It would take a lot of additional code to get this feature in. I think there isn't such a dramatic difference between saying there are no matches and showing no matches from the UX standpoint, and therefore the additional work, maintenance burden, and complexity aren't justified. Of course, if you insist that this feature is crucial, I can still add it. |
Ok if it'd require a lot of extra work we can leave it out
I think so :) |
Ok. I've pushed a fix for the combobox widths. Right now, these controls use different implementations (number of extra slots uses SUI dropdown). My plan is to replace the other ones once this PR is merged so we don't do too much in a single PR. Meanwhile you can adapt this to the time picker, for instance. Let me know if that works for you. |
As long as the look is consistent across the different dropdowns it should be fine |