-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
A11y: Wrap ToC Block within nav tag #6084
Conversation
This reverts commit 4e2f9c1.
✅ Deploy Preview for plone-components canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tishasoumya-02 you know the saying:
The road to hell is paved with good intentions?
This pull request right here brings in mind to me this quote because your
intention is good but the outcome is not.
Many times an aria-label will do worse to have it than not.
Have a look at this video that I will upload, it shows some of the issues of having aria-label on the toc links
toc-entry.mp4
Have a look at this nice toc:
https://www.a11y-collective.com/blog/layout-tables-accessibility/
https://webaim.org/articles/visual/
https://www.w3.org/TR/WCAG20-TECHS/G64.html#G64-description
https://www.w3.org/TR/WCAG21/#label-in-name
if we look at w3 and other popular a11y websites, none of them employ
the technique that you propose.
As long as we ensure that we have proper listing with depth information
plus a good heading to mark table of contents we don't need to mess
with the link information.
A user using the screen reader might use the heading rotary and find
table of contents and from there it finds the list and links.
Have a look at this survey
https://webaim.org/projects/screenreadersurvey10/#finding
Thanks! @ichim-david for the in-depth explanation, from the contents you shared , I agree aria-labels can mislead , but if we want the screen reader to read as '....... ToC link' so the users know it is a ToC link , can we use aria but in a more descriptive way eg- ' Table linearisation a Table of Content link' something similiar in this line. |
@Tishasoumya-02 aria-labelledby gives a better solution that aria-label but even it suffers from replacing the links title from the "Link Rotary" on VoiceOver app. Please investigate some more on this issue and if you find something that is worth investigating do share it. |
Sure, Thanks @ichim-david ! |
@ichim-david I think there is room for two IMO valid opinions here:
I don't have a strong opinion here. I wasn't able to find any good sources on this topic. However, I am not sure if websites that write about a11y are a "good enough" source for best practices and decisions. Maybe @polyester or our friends from redturtle (@pnicolli @cekk et al) have an opinion on the topic. |
I am in favor of this option. You have yet to convince me that option 2 is viable given that even the author who investigated this technique hasn't used this technique for its own table of contents on the page itself: All of the a11y blogs that I have read have not employed this technique and although yes, just like blogs about performance can suffer from performance issues, if this was an established pattern I think there would be more information about it and used more broadly. |
I would go with option 1 as well for now, but improve the HTML structure. Currently, the ToC block seems to produce a
which would already be improved by having the div replaced as a |
I'd agree with using Option 1 here. Adding the navigation role as suggested above with a descriptive label along with the heading of the ToC provides enough context to the user about what the links will do. You could use an <nav aria-label="Contents on this page">
<h2>Contents</h2>
<ul> ... </ul>
</nav> GOV UK Publishing Components - Contents list is a good example of a well researched and accessible ToC |
@Tishasoumya-02 @ichim-david @polyester @JeffersonBledsoe thanks for your valuable input folks! Then let's go with option 1 and improve the HTML structure of the toc block. @sneridagh I guess this is considered to be a breaking change. Can this go into Volto 18? We are still in alpha, right? |
@tisto Yeah, no problem by being breaking. We will have to write the breaking notice and the upgrade guide update. @Tishasoumya-02 could you take care in the next days? |
Sure @sneridagh |
@sneridagh @Tishasoumya-02 I don't think we can use any of the changes from this pull request. it would make sense in my opinion to open a new pull request with changes to the Table of contents block. It's still not clear to me though what is going to be proposed exactly, if we should have a proposal and after feedback it's implemented or we give feedback after whatever you propose to change. I say this because I've seen the comment from @JeffersonBledsoe #6084 (comment) where he gives the example of how Gov Uk does it and then the simple nav wrap mentioned by @polyester. I think if we have a proposal and we agree on the markup it would mean fewer changes in the pull request afterward no? |
Reading through how Gov uk implements the content of table shared by @JeffersonBledsoe , I made some changes in the existing View.jsx of ToC Block (gist of changes below) , should I implement this in this PR for all to test? <nav className= 'table of contents default' aria-label= 'Table of Contents' >
<div className= 'table of contents main default' >
<h2>Content</h2>
<ul> <li><li> </ul>
</div>
</nav> |
@Tishasoumya-02 Is the |
Not really, we can remove it. As for accessibility it does not serve any purpose |
@Tishasoumya-02 I suggest the following:
<nav className= 'table of contents main default' aria-label= 'Table of Contents' >
<h2>Table of Content</h2>
<ul> <li><li> </ul>
</nav> This way the user in need of a screen reader can find the section either from the Landmark rotary which will find "Table of contents navigation" or will use the Headings rotary and know that what follows is a table of contents. |
One additional thing we also need to consider is the potential for there to be multiple Table of Contents blocks on a page. We don't want every ToC Block to have a nav of |
@JeffersonBledsoe that's a good point, perhaps the aria-label could contain the title. If you don't enter anything you get the fallback for Table of contents which is with Formatted Message. |
In some documentation projects, it is not an uncommon use case. It allows to break up a wall of text with headings and explanatory text for greater legibility and context. Example of multiple ToCs:
...and so on. |
If we could use a different landmark like section or main instead of nav , would that be an option? |
- Also use the Table of contents message from the TOC schema to signal what content it is when there are no headings to show in edit. - Rollback default showing of Table of contents h2 since it would be breaking change as opposed to how it works now.
…efaultTocRender ToC templates - Since the fallback would never resolve to true there is no point in referencing them instead we show Table of contents if there are no headings to show
…sages - I want to avoid getting rid of the i18n translated strings and keep CI happy
@davisagli @pnicolli I wanted todo some more changes such as making actual use of the data.title fallback which was translated saying "Table of contents" by setting that value as default to the title. Upon checking https://light-theme.kitconcept.io/ and seeing that you only have the title option empty by default Given the fact that the styling references the class in order to style it, it won't affect your projects. |
@ichim-david I don't have a strong opinion about whether or not we should have a default title (my gut feeling is to leave it as is with no default), or about whether or not we should put "table of contents" in the aria-label when there's no title (my gut feeling is to leave it out, if screen readers will indicate the nav element in some way anyway). |
@Tishasoumya-02 @ichim-david Let's wrap things for the final release, and I think this is a good one to be included, so let's move this forward, the change is sound and it already improves things. We just need blessing from someone from the a11y team. As I see, it's breaking and therefore needs proper news item |
I'd agree with @davisagli here; minimal intrusion is better so leave as is with no default. And agreed with @sneridagh ; it's an improvement, so let's wrap up and get it in. |
@sneridagh @plone/volto-accessibility I updated the upgrade guide. I think it's ready. |
@sneridagh this is ready for merging I see the upgrade notice is added and .breaking. To me this is a very soft or not at all breaking given the fact that we modify the wrapper of the table of content block and light-theme hooks on the class and not the html element which we should always do so as html elements can change but classes can remain stable. |
@davisagli @sneridagh Honestly if we look at the initial issue where @Tishasoumya-02 wanted to add "The link should be marked as Table-of-Contents-Link" I think I shouldn't have asked if we want to have "Table of contents" aria-label to the nav when we have no title and simply add it as this would have achieved the desire to let the user know that the nav is for "Table of contents". If you add a title then that would be the aria-label. Right now we are doing less by simply saying that it's a nav. Hopefully no one adds the table of contents without a title to make sense. |
@sneridagh Can we merge this? |
@sneridagh This is ready to merge, given that only change is from div to nav it's a safe change as we have notified the breaking. |
* main: (111 commits) Moved `applyBlockDefaults` one component up so the style is computed correctly (#6451) Fix useSelector is returned a different result when called with the s… (#6450) Fix page changes not being announced by assistive technology when navigating using the client-side router (#5288) BlockStyleWrapper aware of block themes (#6445) A11y: Wrap ToC Block within nav tag (#6084) Fix backend error when there is no query supplied (#6423) Added upgrade guide fix for HMR (#6446) Fix CSS lint in Volto Slate (#6444) Release 18.0.0-alpha.47 Release generate-volto 9.0.0-alpha.20 Release @plone/scripts 3.7.0 Release @plone/registry 2.0.0-alpha.0 Improve @plone/registry release-it config `@plone/registry` as ESM module, move to TS, complete documentation (#6399) [Next.js] Better Vercel deployment (#6441) Replace all `yarn` appearences with `pnpm` (#6433) Add deprecation notices to the Upgrade guide (#6426) Clean up #6422 (#6443) Rename page title from Frontend to Volto UI (#6438) URL-Management control panel: Add missing translations (#6436) ...
Fixes #6082
📚 Documentation preview 📚: https://volto--6084.org.readthedocs.build/