Problem/Motivation
The countdown message isn't associated with the corresponding field in any way. Since it is after the particular field it is more or less hidden for screen reader users. The field and the count down message could be linked with an aria-describedby.
Steps to reproduce
- Set a Maxlength on a field.
- Type into the text field while using a screen reader.
Proposed resolution
Perhaps we can use drupal.announce in some way also (a direct update on every keystroke might be too distracting and cognitively demanding but an announcement like "only 10 characters left" or "you have reached the hard limit" might be helpful).
A good place for inspiration in regards of the character count might be also the gov.uk design system: https://design-system.service.gov.uk/components/character-count/
Remaining tasks
- ✅ Get maintainer approval for the proposed resolution
- ✅ Implement resolution
- ✅ Write test coverage (contact a maintainer if you need help)
- ✅ Maintainer review via the UI
- ❌ Maintainer Code Review #1
- ❌ Maintainer code review #2
- ❌ Merge into dev branch, with credit to author and participants
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3259480-MaxLength-ScreenReader-Test.mp4 | 1.08 MB | sandeepsingh199 |
| #9 | 3259480-9.patch | 3.6 KB | tguerineau |
| #7 | maxlength-screen-reader-test.mp4 | 3.03 MB | cedewey |
| #3 | make-countdown-message-screen-reader-compatible-3259480-3.patch | 1.07 KB | tguerineau |
Issue fork maxlength-3259480
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
cedeweyComment #3
tguerineau commentedPatch Update
Summary:
This patch addresses the issue of making the countdown message screen reader compatible. The primary changes involve associating the countdown message with its corresponding field using the aria-describedby attribute and announcing important character count milestones using Drupal.announce().
Details:
1. Associated the countdown message with its input field using the aria-describedby attribute, improving accessibility for screen reader users.
2. Introduced logic to announce when there are only 10 characters left, when there are no characters left, and when the character limit is exceeded. These announcements are wrapped in Drupal.t() to ensure they're translatable, enhancing compatibility for multilingual sites.
3. The changes were tested using the Screen Reader extension for Chrome.
Looking forward for reviews and feedback.
Comment #5
cedeweyComment #6
cedeweyComment #7
cedeweyHi Tom'as,
Thanks for another contribution to this project. This is awesome! I just tested this using the Screen Reader Chrome extension as well and it works as expected for me. I'm assigning this to Heather to see if she approves of this behavior as well and to review the code.
Here's a video of my test session.
Comment #8
joevagyok commentedTests are failing and we need to test the existence of the aria-described by field.
This should be a switch instead of else ifs.
Comment #9
tguerineau commentedThank you for taking the time to review this patch!
Patch Updates:
- Use
switchinstead ofelse if.- Testing aria-describedby Attribute:
testAriaDescribedbyAttribute(), is introduced to ascertain the correct setting of the aria-describedby attribute by the maxlength.js script.Test Failures Noted:
We've observed the following test failures in the CI.
Unfortunately, I have been unable to run the tests locally, which has limited my ability to further diagnose and resolve the test failures.
Potential Causes:Given the nature of the updates in the patch, it's plausible that the changes to the character count announcements and their respective behaviors might be influencing the test outcomes. Specifically, the additional announcements or altered text/behaviors might not align with the current test expectations.
Next Steps & Request for Assistance:
- If the test failures are related to the updated announcement behaviors, the tests might require updates to reflect the new expectations.
- Any advice, suggestions, or contributions to further diagnose or fix the test failures would be invaluable.
Comment #10
sandeepsingh199 commentedHi @tguerineau,
I reviewed your latest patch in local & found its working as expected. I hope you can mark this issue to Needs Review state.
Comment #11
tguerineau commentedThank @SandeepSingh199 for taking the time to review the patch and providing valuable feedback!
I have updated the issue state to "Needs Review" as per your suggestion.
Comment #15
sokru commentedBasically just rerolled the patch into MR and added few tests. Tested also manually, so setting the status to RTBC.
Comment #16
simohell commentedAnnouncement works, but I would recommend following the UK gov style of adding more information to the plain "0/250" description part. A screen reader user can access the text but without context. Fe. Voiceover tells the user there is additional information available and accessing that outputs "0/250" - it woulg be helpful I think even just to add the word "characters" to give context.
Comment #17
joevagyok commentedGreat job! I will make a review.
Comment #18
joevagyok commentedComment #19
joevagyok commented@simohell where do you see this "0/250" description exactly?
Comment #20
simohell commentedOh. Sorry, that "0/250" case was using a custom setting. So it's not something with the module / patch. This looks great. (the text is editable in the UI and is announced, so if not using the default, the responsibility is with the site builder)
Comment #21
joevagyok commentedThanks, I thought it was something with the patch.
Comment #26
joevagyok commentedComment #27
joevagyok commented