Tab nav link error count is not correctly pluralised for screen readers
See original GitHub issueIssue Summary
While investigating https://github.com/wagtail/wagtail/issues/9497 it seems there is a similar issue on the Tab nav link (the tab buttons) that does not correctly pluralise the error counts.
Steps to Reproduce
- On bakerydemo, edit a page, create a single validation error (e.g. remove the title and make it a blank title)
- Click save draft, the page will reload with the error count shown in the tab (e.g.
Content (1)
- Right-click on the red “1” in a circle on the tab and inspect it in your browser’s developer tools
- Observe that the label for screen readers is “Errors Count: 1 Content”
- Expected: This label should be correctly labelled for single / plural errors and be easy to read
- Actual: It uses
errors
noterror
and actually is confusing as it seems like the error is with Content but Content here refers to the tab.
- I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: (no)
Potential solution
In the file - https://github.com/wagtail/wagtail/blob/main/wagtail/admin/templates/wagtailadmin/shared/tabs/tab_nav_link.html
- We should reverse the DOM order so that the
{{ title }}
is before the error count div - this will help with readability and also honours the visual styling where the number is shown after the tab title. - The
data-tabs-errors-count
could be changed to be the visual representation only (via aria-hidden or similar) - I would think we should not be using
Count
as a proper noun and instead have a lowercasec
forcount
. Maybe not even Errors, this is probably just a grammar typo. - We can then use a different translation mechanism for the error count - see https://docs.djangoproject.com/en/4.1/topics/i18n/translation/#std:templatetag-blocktrans so that the label for screen readers contains the whole thing.
Something like the following could be a good start, but this will read “Content 1 error” and “Content 3 errors” - we should be careful with assuming the value of the tab and trying to put that in the sentence. Maybe an easy way around this is to wrap the error label in brackets instead.
<a id="tab-label-{{ tab_id }}" href="#tab-{{ tab_id }}" class="w-tabs__tab {{ classes }}" role="tab" aria-selected="false" tabindex="-1">
{{ title }}
<div data-tabs-errors class="w-tabs__errors {% if errors_count %}!w-flex{% endif %}">
<span data-tabs-errors-count aria-hidden="true">{{ errors_count }}</span>
<span class="w-sr-only">{% blocktrans trimmed count errors_count=errors_count %}1 error{% plural %}{{ errors_count }} errors{% endblocktranslate %}</span>
</div>
</a>
Technical details
- Python version: 3.0
- Django version: 4.1
- Wagtail version: 4.2a (in development)
- Browser version: Firefox 106
Issue Analytics
- State:
- Created a year ago
- Comments:23 (20 by maintainers)
Top Results From Across the Web
Accessibility - Screen reader not reading tabs count
If I give the role="tab" to the li items, it reads as 1 of 5/ 2 of 5 etc. but it does not...
Read more >[a11y][Tabs] Tab list does not have accurate tab count #2442
Issue summary Screen reader users are currently not receiving an accurate count of the number tabs with any browser + screen reader ......
Read more >Common Accessibility Errors
Tab through the page and make sure that everything on the page is still accessible in zoom. Is there a 'skip to content'...
Read more >NetLogo 6.3.0 User Manual: Programming Guide
A link is represented visually as a line connecting the two turtles. Procedures. In NetLogo, commands and reporters tell agents what to do....
Read more >News Archive
Fixed an issue where AutoComplete was not working correctly due to ... allow tab navigation in the properties tab and also allow screen...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@salty-ivy I think you are right about the JS stuff - searching in the code for
data-dabts-errors
uncovers this file.client/src/entrypoints/admin/page-editor.js see
initErrorDetection
Sorry - not sure on that.