-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Bug]: Toggle storybook component needs better doc for hideLabel & consideration to not require aria-labelledby be used in conjuction with it. #12999
Comments
This is stemming from changes made in #12974
@janhassel What do you think here? Updating the storybook props description to clarify the relationship between these two props makes sense, but curious if you feel they should be explicitly linked even when |
I agree, the documentation could be improved to describe the behavior better. @fbarroso24 I'd be interested in your specific use case that leverages If you're an IBMer, feel free to reach out via slack ( |
@janhassel it depends on the use case really. The following link describes various ways to apply labels that are A11Y compliant: https://www.w3.org/WAI/tutorials/forms/labels/. The key difference is where the label resides. For this Specifying a label on the Toggle and a label via the |
I see your point, @fbarroso24 @tay1orjones I'm unsure how this would best work in a component library while trying to ensure accessibility requirements are met. If we wouldn't wanna verify there is an actual Long term, it may be worth exploring if the current |
@janhassel Yeah, this is probably the best course of action. Also ensure that it is well documented. This could include
|
@tay1orjones I opened a PR with the discussed changes.
I tried to describe this behaviour directly in the prop docs. Let me know if you'd like to also see it in the general documentation. |
Package
@carbon/react
Browser
Chrome
Package version
11.21.0
React version
any
Description
The new functionality of
hideLabel
in@carbon/react: "1.21.0
isn't documented very well. For example, when I sethideLabel={true}
I was expecting it to hide the label right away but it did not. Rather setting it totrue
put thelabelText
on the side of the toggle & whenhideLabel={false}
the label was on top of the toggle (see screenshot below).Only after discussing internally, was it learned that for the Toggle's label to truly be hidden it requires
hideLabel={true}
AND that thearia-labelledby
attribute be set properly (see screenshot below).So the ask on this one is to see if we can better document the storybook's
hideLabel
andaria-labelledby
props so that it is clear that in order forhideLabel
to trigger it requires that thearia-labelledby
prop also be set. Here's a screenshot of the current toggle storybook doc.NOTE: I still think it might worthwhile to consider simplifying things and simply make
hideLabel
work without being tied toaria-labelledby
. The reason being is that thefor
attribute on the label can also be used to tie a label to aToggle
component and that should be A11Y compliant as well. So by requiringaria-labelledby
be used in conjunction withhideLabel
it seems to not be supporting the alternatefor
attribute with the label. (see below for an illustration)Suggested Severity
Severity 1 = Must be fixed ASAP. The response must be swift. Someone from the team must drop all current work and be immediately reassigned to address the issue.
Reproduction/example
https://stackblitz.com/edit/github-ccn2fg-gw95df?file=src/App.jsx
Steps to reproduce
Have a look at the stackblitz and see that while it is a valid Toggle with the label specified separately the
hideLabel={true}
doesn't actually hide the label unless thearia-labelledby
prop is used on theToggle
component.The Toggle storybook doc should be updated to mention this or simply remove the requirement that the
aria-labelledby
prop be also used.Code of Conduct
The text was updated successfully, but these errors were encountered: