-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 missing lang attribute #2538
Conversation
Accessibility tests warn that the HTML element requires a lang attribute. See: https://dequeuniversity.com/rules/axe/2.4/html-has-lang?application=AxeChrome Ideally the lang attribute's value would be set to whatever language the user is using for Storybook, but that would require adding configuration, so this seems like a short term fix that addresses the immediate issue.
Codecov Report
@@ Coverage Diff @@
## master #2538 +/- ##
=======================================
Coverage 16.87% 16.87%
=======================================
Files 307 307
Lines 7792 7792
Branches 794 778 -16
=======================================
Hits 1315 1315
- Misses 5825 5857 +32
+ Partials 652 620 -32
Continue to review full report at Codecov.
|
I get that this will solve some warning in some tool somewhere. I truly appreciate the effort of you fixing it. I'm a little concerned about if by merging this we'd not actually be providing the user-agent with potential wrong information, and by that making it worse for some small percentage of users. What do you think? |
@ndelangen Yes, this is a problem. Per the website I linked:
So if we leave it unset, the screen reader will use whatever the user has set as default. That's why ideally we allow the user of Storybook to set the language, which is then set in the lang attribute. It would be nice to amend this commit with that change, but it's more impactful than just setting one value now. |
Since the iframe would display mostly story content, I would think that the viewer's screen reader is most likely also set to the story content as a default. The only English we provide in the frame is from the info addon. I don't think that justifies assuming the entire page is |
@danielduan Agreed that it doesn't justify assuming it for everyone. That's why I proposed making it configurable in my PR comment. What would it take to accomplish that? Adding it to preview-head.html works, but it places the responsibility for the page served by Storybook being accessible on the developer. I think that responsibility lies with Storybook. |
@Primigenus It could be an option within the Options addon but I'm still not sold on this:
To me, if a component has labels in German and another component in French, the writer of the individual stories should have the responsibility to configure the story itself to change the lang attribute. I'm not quite sure how a component story could be added without having permissions to To have it as an option in the addon is a possibility, but I'm concerned about maintainability in the long term since this doesn't appear to be a commonly requested feature. Maybe others can chime in? |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 60 days. Thanks! |
Well, what's shown in preview iframe is the responsibility of the developer anyway. @Primigenus are you interested in adding that? |
closing in favor of #3065 |
Issue: #2351
What I did
Accessibility tests warn that the HTML element requires a lang attribute. See: https://dequeuniversity.com/rules/axe/2.4/html-has-lang?application=AxeChrome
Ideally the lang attribute's value would be set to whatever language the user is using for Storybook, but that would require adding configuration, so this seems like a short term fix that addresses the immediate issue.
How to test
Run accessibility tests on the iframe and find that they no longer warn about the HTML lang attribute.