-
Notifications
You must be signed in to change notification settings - Fork 65
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
Form.Autosuggest Accessibility - Label Association #2436
Comments
Might be worth bringing this up in the next Paragon WG meeting |
Topic for Paragon WG, ask:
|
Wrapping a label around a control works (well, with the exception of the bugs you identified) but it isn't Best Practice. Programmatic association (for= attribute on a , pointing to a unique ID on the control, or aria-labelledby on the control, pointing to a unique ID on the labeling element, or aria-label) is preferred. More specifically, if the label isn't "programmatically determined", it'll throw a warning or error in automated testing. My preferred solution is to add a new labeling option (as a new default) for Paragon controls, to get the Form.label in the preferred format (now that we're trying to deprecate floating labels). An Open edX community partner requested this option be added some time ago as well. |
Based on the examples we have on the docs site for labels, and the fact that we're moving to deprecate floating labels, I'm leaning towards
There are, however, components that don't follow the patterns in those examples (such as TextFilter), so it's likely worth investigating other options/gathering other opinions too. |
verify this works and properly associates the label with the input textbox <Form.Group>
<Form.Label
<h3> Select an option from below </h3>
</Form.Label>
<Form.Autosuggest>
<Form.AutosuggestOption />
<Form.AutosuggestOption />
{...more options}
</Form.Autosuggest>
<Form.Group> if not find a way to fix it |
One of the more complex issues involves how labels are associated with the component's
<input>
element. Unless afloatingLabel
attribute is provided, there will be no label created for the<input>
. This means that developers will need to implicitly associate a label by wrapping the<Form.Autosuggest>
in<Form.Label>
. See below:Unfortunately, while this does solve the problem of associating a label with the
<input>
, this presents another issue where the dropdown icon button (dropdown arrow) doesn’t behave as expected. It appears that the wrapping done by the<Form.Label>
is interfering with the way the icon button receives itsonClick
event. The icon button will expand the list, but will not close it. This only occurs when clicking exactly on the nested<svg>
element.Screen.Recording.2023-06-22.at.12.25.26.PM.mov
A possible fix for this would be to remove the
<Form.Group>
that is provided inside of the<Form.Autosuggest>
and require developers to always wrap this component in a<Form.Group>
when implementing, which also provides the ability to add in a custom label.Alternatively, effort could be put towards figuring out why the button isn’t behaving correctly when the component is wrapped in a
<Form.Label>
. Perhaps there is some propagation getting in the way that we can disable?The text was updated successfully, but these errors were encountered: