-
Notifications
You must be signed in to change notification settings - Fork 2k
Improve screen reader support for credit card error messages #103846
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
base: trunk
Are you sure you want to change the base?
Improve screen reader support for credit card error messages #103846
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~37 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~797 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~222 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
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.
I know this is a WIP (maybe? it still says that in the title) but from a Payments perspective, this looks like a nice improvement!
Thanks for reviewing it @sirbrillig! Sorry, I just forgot to update the title when I made this ready for review, updated it now. 👍 |
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.
@@ -76,6 +78,8 @@ export default function Notice( { | |||
status, | |||
text, | |||
theme = 'dark', | |||
ariaLive, | |||
role, |
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.
role, | |
role = 'status', |
Nit: In my opinion this is easier to read and follows the same pattern as the other props with a default value in this component (like theme
)
@@ -45,6 +45,8 @@ interface NoticeProps { | |||
theme?: 'light' | 'dark'; | |||
text?: ReactNode; | |||
children?: ReactNode; | |||
ariaLive?: 'off' | 'polite' | 'assertive'; | |||
role?: string; |
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.
Could we maybe limit these a bit for role that make sense?
In this component I would imagine these would be a good start: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles#4._live_region_roles
What do you think?
@gcsecsey, I noticed that VoiceOver didn't read the Cardholder name field when an error occurred. Is that expected? I'm not sure if that should be part of this PR, but when an error occurs, the focus is not set to the error field, as a result, VoiceOver don't read the error message. |
Fixes DOTCOM-13375 Make checkout form errors accessible to screen readers
Proposed Changes
This PR ensures that the error notice is announced by VoiceOver when there are form errors.
StripeErrorMessage
Component:span
to a styleddiv
for improved semantics and flexibility.aria-live="assertive"
to ensure screen readers announce error messages. This doesn't work with VoiceOver specifically.aria-invalid="true"
to indicate the presence of an error.ariaLive
androle
props to theNotice
component (client/components/notice/index.tsx
).<div>
of the notice, allowing for custom ARIA live region and role attributes.BaseNoticeOptions
,NoticeOptions
, andNoticeActionOptions
types to includeariaLive
androle
properties (client/state/notices/types.ts
).ariaLive: 'assertive'
androle: 'alert'
, ensuring that screen readers announce the error as soon as it appears.Why are these changes being made?
Form validation errors on the checkout page are not currently announced by screen readers.
Testing Instructions
CleanShot.2025-06-02.at.15.59.57.mp4
Pre-merge Checklist