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(character-count): prevent screen reader announcing value when submitting a form #6792

Merged
merged 2 commits into from
Jul 4, 2024

Conversation

DipperTheDan
Copy link
Contributor

This work fixes a bug whereby a screen reader announces the character count 'You have n characters remaining' message after form submission. To address this, we have defaulted aria-live to off until the input is focused where it will then have the value of polite.

fixes #6181

Proposed behaviour

Default aria-live value is off until the input is focused where it will then have the value of polite. Once the input is blurred, the aria-live value will be reset to off.

Current behaviour

By default, the aria-live value is always polite.

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

N/A

Testing instructions

I have created a test story in Form called Mock form for aria live demo. In this demo you should check:

  • Each component has an aria-live value of off by default (you can find this value by looking at the div element with data-element="visually-hidden-character-count"). When the input is focused, the aria-live value should change to polite.
  • We will need to ensure that the inputs are still announced correctly by the screen readers when typed in.
  • When the form is submitted using the Save button, there should be no update provided regarding the character counts in any of the inputs.

@DipperTheDan DipperTheDan self-assigned this Jun 20, 2024
@DipperTheDan DipperTheDan force-pushed the FE-6054_character-count-aria-live-fix branch from 17fb574 to 313ee41 Compare June 20, 2024 09:42
@tomdavies73 tomdavies73 marked this pull request as ready for review June 24, 2024 14:53
@tomdavies73 tomdavies73 requested review from a team as code owners June 24, 2024 14:53
@tomdavies73 tomdavies73 self-requested a review June 25, 2024 08:46
@Parsium Parsium self-requested a review June 25, 2024 09:03
src/components/textbox/textbox.pw.tsx Show resolved Hide resolved
src/components/textbox/textbox.component.tsx Outdated Show resolved Hide resolved
src/components/textarea/textarea.component.tsx Outdated Show resolved Hide resolved
src/components/form/form-test.stories.tsx Show resolved Hide resolved
src/components/password/password.pw.tsx Outdated Show resolved Hide resolved
src/components/text-editor/text-editor.component.tsx Outdated Show resolved Hide resolved
src/components/password/password.pw.tsx Outdated Show resolved Hide resolved
src/components/textbox/textbox.component.tsx Outdated Show resolved Hide resolved
src/components/textarea/textarea.component.tsx Outdated Show resolved Hide resolved
src/components/form/form-test.stories.tsx Outdated Show resolved Hide resolved
@DipperTheDan DipperTheDan force-pushed the FE-6054_character-count-aria-live-fix branch 2 times, most recently from 0174d81 to 6483ec9 Compare June 25, 2024 15:25
@harpalsingh
Copy link
Member

Did a review of this with @tempertemper, all good 👍

…mitting a form

This work fixes a bug whereby a screen reader announces the character count 'You have `n` characters
remaining' message after form submission. To address this, we have defaulted aria-live to off until
the input is focused where it will then have the value of polite.

fixes #6181
@DipperTheDan DipperTheDan force-pushed the FE-6054_character-count-aria-live-fix branch from 6483ec9 to 17ff11f Compare July 4, 2024 09:41
@DipperTheDan DipperTheDan merged commit 6bf574a into master Jul 4, 2024
21 checks passed
@DipperTheDan DipperTheDan deleted the FE-6054_character-count-aria-live-fix branch July 4, 2024 10:45
@carbonci
Copy link
Collaborator

carbonci commented Jul 4, 2024

🎉 This PR is included in version 140.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Ensure character count message is not read out after form submission
6 participants