ComboboxControl: Fix accessible association of help text#76761
ComboboxControl: Fix accessible association of help text#76761
help text#76761Conversation
| expect( label ).toHaveAttribute( | ||
| 'data-wp-component', | ||
| 'VisuallyHidden' | ||
| ); |
There was a problem hiding this comment.
Removed for testing implementation details.
| onChange={ onInputChange } | ||
| aria-describedby={ | ||
| help | ||
| ? `components-form-token-input-${ instanceId }__help` |
There was a problem hiding this comment.
Ideally, TokenInput wouldn't hardcode any IDs internally and would instead receive id, aria-owns, aria-describedby, etc. from its parent. That refactor would make this kind of fix trivial, but it touches both consumers (ComboboxControl and FormTokenField) plus SuggestionsList, so it's out of scope here.
There was a problem hiding this comment.
Yeah, this is not ideal but I understand that the proper fix would be more involved ( I can see that you had initiall tried useBaseControlProps but then reverted to straight aria-describedby). Should we at least add an inline comment to note the tradeoff ?
|
Size Change: +24 B (0%) Total Size: 7.66 MB
ℹ️ View Unchanged
|
|
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. |
|
Flaky tests detected in 0cf3b88. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23436566986
|
ciampo
left a comment
There was a problem hiding this comment.
Pre-approving, we can merge once feedback is addressed 🚀
| __next40pxDefaultSize: true, | ||
| label: 'Select a country', | ||
| options: countryOptions, | ||
| help: 'Select the country you currently reside in.', |
There was a problem hiding this comment.
Is this just for testing purpose, or do we want to change the default story? Alternatively, we could have a WithHelpText separate story.
| onChange={ onInputChange } | ||
| aria-describedby={ | ||
| help | ||
| ? `components-form-token-input-${ instanceId }__help` |
There was a problem hiding this comment.
Yeah, this is not ideal but I understand that the proper fix would be more involved ( I can see that you had initiall tried useBaseControlProps but then reverted to straight aria-describedby). Should we at least add an inline comment to note the tradeoff ?
What?
Fix the
helpprop onComboboxControlso that it is programmatically associated with the combobox input viaaria-describedby.Why?
The
helptext was being rendered visually (viaBaseControl) but had noaria-describedbylinking it to the combobox input. Screen reader users would not hear the help text when interacting with the control.How?
ComboboxControl, passaria-describedbypointing to theBaseControl-rendered help element toTokenInputwhenhelpis provided.TokenInput, merge any externally passedaria-describedbywith the existing howto description ID, so both are present on the input.Also adds
helptext to the default Storybook story.Testing Instructions
npm run storybook:devand navigate to theComboboxControldefault story.aria-describedbyreferencing the help text element'sid.Use of AI Tools
Authored with Cursor (Claude).