-
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
Add support for disabled drop down items in SelectControl #15976
Add support for disabled drop down items in SelectControl #15976
Conversation
…ectControl` as 'disabled', which translates to the `disabled` attribute being added to the HTML `option` element.
Discussed during today's accessibility bug scrub. Agreed we don't see any accessibility issue in implementing an |
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.
It's not clear to me: What's the purpose of the "- Select -" option existing at all? My initial worry was that the block allows for the value to be "unset", which we'd regress on with the changes here. But the behavior from choosing the value seems to be invalid (displays a message "Your site has no tags"). Perhaps it's meant as a fallback condition for sites with no taxonomies registered?
It's to provide a default option as a placeholder, so that it doesn't look to the user as though the first option is selected - it hasn't, if you check the value of the select.
This won't happen - the initial value is
It's for anywhere that a dropdown is used and the list of One way you can test this is to create a simple block with a drop down in the block controls. Give the drop down a single value. At the moment, the result would be that it looks to the user as though that single option is selected. If you use JS to get the value of the select, it will be empty (so not what the user sees). If the user attempts to select that single option, nothing actually happens - the value never changes. |
@gziolo Did you just want a gut check from the a11y team? Given there are no issues identified, how are we on getting this approved? |
Created a local copy of the SelectComponent from @wordpress/components which implements the change proposed in WordPress/gutenberg#15976. The Newspack's component now uses the local assets/components/src/select-control-gutenberg-modified. Once the PR is implemented, we should switch back to the WP component. Added the first disabled option in the Components Demo Wizard. Also updated the labels there. Updated the SelectComponent's CSS, improved the disabled SelectOption visuals.
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, thanks fo the work @philipjohn. I have used the pattern you described of a disabled first item in other projects and it was very useful, and looks like a good fit for the tag cloud here.
No objections from me. |
Thanks for working on this! No objections from me in having the ability to disable an option. Not sure about the specific usage on the Tag Cloud taxonomy select. One of the taxonomies must be always selected, so I'm not sure I understand what is the purpose of the |
@afercia In the absence of a default, the browser may select the first option against the user expectation. You can see an example in Automattic/newspack-plugin#83 This could also affect the tag cloud, hence why the default disabled option is included here. |
@afercia thanks for the feedback, since the - Select - is already there in the "new" tag cloud and this just makes it disabled I would say it's still a step in the right direction. Could explore dropping it in a different issue, but don't see that as a blocker to this. Thanks again @philipjohn |
That sounds like a bug in the code, which is assuming a state change 🙂 Native selects don't work that way. I'd say the component fails in reproducing the native, expected, behavior.
Will create a new issue... |
Description
Fixes #11270. Adds support for marking options within a
SelectControl
as 'disabled', which translates to thedisabled
attribute being added to the HTMLoption
element.How Has This Been Tested?
Screenshots (jpeg or gifs if applicable):
Before:
After:
Types of changes
This changes improves an existing component and updates one use of that component to demonstrate how it can be used.
Checklist: