-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Components: ComboboxControl supports disabled items #61294
Components: ComboboxControl supports disabled items #61294
Conversation
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
237e3fb
to
d06d3f3
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +825 B (+0.05%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
Flaky tests detected in d06d3f3. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8913331768
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@retrofox Thanks for the PR. One accessibility note, you should not be restricting arrow navigation for disabled options. By doing that, you are taking the ability away from keyboard-only users to hear if an option is disabled or not. I see you are already using the aria-disabled
attribute on the disabled options, this is good, but users would likely never hear this announced since you are skipping any index that is disabled on arrow key down.
Hi, @alexstine. Thanks for your feedback.
Good point. This is something that I've been thinking about, too. However, I followed the behavior of the native element. It isn't possible to select the disabled option by using the keyboard. Anyway, we can make them accessible if we consider this to be the proper behavior. |
@retrofox I think at minimum, the option should at least be discoverable even if it is announced as disabled. Thoughts @afercia @joedolson? So many bad examples around the web. I fail to understand how people see the experience as fair or equitable when we make things visible in the UI visually but not readable allowed for VI/blind users. |
💯 sgtm |
Again, will defer to others. To me this is not a design issue, this is a question of: what are the constraints we are reaching for as to how this component should behave in an accessible way. If the gray works, go for it. An alternative is to keep the blue selection style, but instead show a semi-transparent white text-color for the disabled item when it's selected — my instincts would be that this would be less jumpy as you navigate. |
Thanks, Joen
I do agree. |
Screen.Recording.2024-05-07.at.09.17.01.mov |
d32e49e
to
a648fe5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, code-wise.
I've left a few optional suggestions, among which there are a couple that should also satisfy all checks.
I'll let design folks do the final approval since there was some design feedback.
packages/components/src/combobox-control/stories/index.story.tsx
Outdated
Show resolved
Hide resolved
a648fe5
to
5cd34a5
Compare
That example is a The example I looked at earlier was this one. There are more here. Generally disabled options don't share a background treatment with enabled ones. Oftentimes disabled options have no hover effect at all, which could also work here imo. |
👍
having no effect, I think, makes sense for |
The mouse pointer is not captured by my screenshots 😅 , but it looks similar to what you shared (believe me :-D ) , with an exception: The style is not applied to the disabled option when the mouse hovers. This is because it applies |
This approach, in my view, is not just good but possibly the best way to handle the disabled state. It's a change proposed by our development team and is also a prevalent practice in other libraries like Ariaakit.
👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems in a good spot to me :)
Thanks for your help. Super valuable. Let's wait for the other 👍s! |
Same :-D Merging... |
What?
This PR supports disabled items for the
<ComboboxControl / >
component.Why?
Because the
disable
option for a Combobox component is a common requirement when using it for the UI.How?
The
<ComboboxControl />
now accepts thedisabled
property, which is propagated to theSuggestionsList
one.The implementation checks if the option is disabled. If so, it does not allow selection in the respective event handler functions.
Let's remark that the disable options are not selectable (by clicking on it or pressing the
enter
key), but they are discoverable and can make the implementation a11y-friendly.Testing Instructions
This PR adds a new story to test the
disable
items:ENTER
keyScreen.Recording.2024-05-03.at.07.09.32.mov
Testing Instructions for Keyboard
Screenshots or screencast