-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: label multiple / composed inputs correctly #42630
Comments
One idea that I though we could explore, is to:
Also, an alternative approach, according to the official W3C's guidelines, would be to use a Thoughts? |
The same approach could be used to avoid displaying nested |
Thanks for creating this issue. A few points I'd like to highlight: I'm not sure 'base' components like
doesn't need to be grouped in a fieldset, as the purpose of this set of inputs is clear. Instead, a set of inputs like:
do need to be grouped in a fieldset with a legend, otherwise their purpose isn't clear at all. That's to say that in most of the cases it's up to the developer to make a decision on whether to use a fieldset + legend. Instead, having this logic built-in in the components doesn't seem ideal to me. Also, for educational purposes, I'd consider to make the usage of fieldset + legend more explicit. Thinking at a simple |
A more concrete scenario (apart from
In which instances should we render a If we agree that
I see your point, but calling components (and props) with names that explicitly refer to the implementation details has the drawback of making the component tied to that particular implementation — hence why I prefer more semantic names. |
Thanks @ciampo for the clarification. Conceptually, I'm not sure we can always determine in advance whether a control needs a fieldset + legend or not. It always depends on the nature of the control, the context, and the quality of the labels. That's why i'd tend to think education and training are more effective rather than 'smart' components that inevitably are based on assumptions. To go through your examples:
OR, not use a fieldset and use more explicit labels instead:
The same consideration applies to the planned SliderUnitControl.
|
What problem does this address?
For more context: this topic was first pointed out in #42118 (comment) and #42095, and recently discussed in #42351 (review)
There are a few instances in the
@wordpress/components
package where multiple input elements are combined into higher-level components without appropriate labelling.As established in previous conversations (see links above) and in w3c's official documentation, the most correct way would be to associate related inputs by wrapping them in a
fieldset
elements, while keeping individuallabel
s for each singleinput
.The challenge in doing so is to avoid nested
fieldset
s when composing components which already internally group multipleinput
s. For example:BorderControl
is rendered byBorderBoxControl
(as discussed in BorderBoxControl: Improve accessibility and labelling #42351 (review))UnitControl
is rendered byRangeControl
and many other higher-level controlsWhat is your proposed solution?
We should come up with a solution that can be applied systematically across all
*Control
components.The text was updated successfully, but these errors were encountered: