Skip to content
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

Fix (16747)(A11y) : Proper Conveyance of Word/Character Count by screen readers #16898

Merged
merged 13 commits into from
Jul 23, 2024

Conversation

2nikhiltom
Copy link
Contributor

@2nikhiltom 2nikhiltom commented Jun 30, 2024

Closes #16747

When the maxCount word limit is set along with the enableCounter prop, the screen reader announcement for the word/character count used to only triggers once when 10 words/characters were left.

Also, no announcements are made when the maximum word/character count is reached. This inconsistency makes it difficult for screen reader users to understand the remaining count and when the limit is hit.

This PR does two things

  1. Incremental Announcements
    It will now make announcements for each of the last 10 characters/words, properly conveying the remaining count.

  2. Max Count Announcement
    An additional announcement will be made when the maximum word/character count is reached, ensuring users are informed when the limit is hit.

Changelog

The useAnnouncer function is updated to track when the maximum limit is reached and ensure announcements are made for each of the last 10 characters/words.

The test cases for useAnnouncer have been updated to reflect the new changes and ensure proper functionality.

Within the component, useAnnouncer is called inside a useEffect hook to manage the timing of announcements.
This is to ensures that same announcements are not repeated unnecessarily and are made after a delay, allowing both the counter and the announcement of the actual text being written to be audible

Testing / Reviewing

  1. Vist textArea playground in deployPreview
  2. Enable enableCounter prop
  3. Set counterMode to character/word (test for both)
  4. Set maxCount to 12
  5. Type character/word:
  6. Run JAWS/VoiceOver and verify that the announcements are made for each of the last 10 characters/words and also verify that Max Count reached announcement is made

Also verify that readOnly status is announced by screenReader when readonly is true

@2nikhiltom 2nikhiltom requested a review from a team as a code owner June 30, 2024 18:21
Copy link

netlify bot commented Jun 30, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 89343d7
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/669e3013e352800008601c40
😎 Deploy Preview https://deploy-preview-16898--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jun 30, 2024

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 89343d7
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/669e30139afa5d00096cdc1e
😎 Deploy Preview https://deploy-preview-16898--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@2nikhiltom 2nikhiltom changed the title [Fix][16747][A11y] : Proper Conveyance of Word/Character Count by screen readers Fix (16747)(A11y) : Proper Conveyance of Word/Character Count by screen readers Jul 1, 2024
Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but one small optimization we could make

Comment on lines 434 to 442
setTimeout(
() => {
if (announcer) {
announcer.textContent = ariaAnnouncement;
setPrevAnnouncement(ariaAnnouncement);
}
},
counterMode === 'word' ? 2000 : 1000
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be best to be sure the timeout is cleared in the useEffect cleanup just in case the component unmounts before the timeout expires. In theory this should be garbage collected but it's a small add for this extra assurance.

// Clear the content first
announcer.textContent = '';
// Set the new content after a small delay
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here with clearing this timeout just in case

@riddhybansal riddhybansal added this pull request to the merge queue Jul 23, 2024
Merged via the queue into carbon-design-system:main with commit bf33904 Jul 23, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[a11y]: [Text area][Playground] - The word/character count not conveyed properly by JAWS
3 participants