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(payments-next): Implement a11y improvements #17056

Merged
merged 1 commit into from
Jun 5, 2024
Merged

fix(payments-next): Implement a11y improvements #17056

merged 1 commit into from
Jun 5, 2024

Conversation

xlisachan
Copy link
Contributor

@xlisachan xlisachan commented Jun 3, 2024

This pull request

  • Added LinkExternal component to have screen readers announce when links open in a new window
  • Moved form elements within and added role='alert' for each error message, so screen reader reads if there is an error for the form element
  • Added tabindex=-1 to disabled form elements that should not be reachable
  • Removed disabled from div so screen reader does not mis-read that the “Name as it appears on your card” field is dimmed when checkbox is checked
  • Increased banner’s z-index as the ‘You need to complete this before moving forward’ tooltip displayed on top of the page banner when scrolling
  • Updated CSS to use border properties instead of <hr> as <hr> was separating information (e.g., 1. Create a Mozilla account / Already have a Mozilla account? Sign in heading and form section, Purchase details list prices and total section)
  • Converted Total label and value to a <li></li> and moved into <ul></ul> as price items should be grouped and improve readability of list price items in Purchase details
  • Updated StripeWrapper so it can be reused later on in Upgrade and Subscription Management

Issue that this pull request solves

Closes: FXA-9708

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.

Copy link

netlify bot commented Jun 3, 2024

Deploy Preview for mozilla-fxa-react failed.

Name Link
🔨 Latest commit 3035ef8
🔍 Latest deploy log https://app.netlify.com/sites/mozilla-fxa-react/deploys/665e09b3dfd46f00082f6088

Copy link

netlify bot commented Jun 3, 2024

Deploy Preview for mozilla-fxa failed.

Name Link
🔨 Latest commit 3035ef8
🔍 Latest deploy log https://app.netlify.com/sites/mozilla-fxa/deploys/665e09b35ff4b10008cfa9eb

Copy link

netlify bot commented Jun 3, 2024

Deploy Preview for mozilla-fxa-payments-server failed.

Name Link
🔨 Latest commit 3035ef8
🔍 Latest deploy log https://app.netlify.com/sites/mozilla-fxa-payments-server/deploys/665e09b3f865930008c7d1ba

Copy link

netlify bot commented Jun 3, 2024

Deploy Preview for mozilla-fxa-settings failed.

Name Link
🔨 Latest commit 3035ef8
🔍 Latest deploy log https://app.netlify.com/sites/mozilla-fxa-settings/deploys/665e09b32281a1000805d003

@xlisachan xlisachan force-pushed the FXA-9708 branch 5 times, most recently from 1884120 to 7b0e3ca Compare June 4, 2024 00:04
@xlisachan xlisachan marked this pull request as ready for review June 4, 2024 14:10
@xlisachan xlisachan requested review from a team as code owners June 4, 2024 14:10
@xlisachan xlisachan changed the title WIP: fix(payments-next): Implement a11y improvements fix(payments-next): Implement a11y improvements Jun 4, 2024
serverInvalid={hasFullNameError}
className="my-6"
>
<Form.Label className="text-[15px] text-grey-400 block mb-1 text-start">
Copy link
Contributor

Choose a reason for hiding this comment

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

Would built-in text-sm (14px) or text-base (16px) work instead of a custom font size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated this to use a custom size for a more unified look with the labels and error messages used in the Stripe Payment Element (15px).

Note: the base font size for the Stripe Payment Element is currently set to 16px.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fly-by comment:

I guess there's no way to update the stripe payment element? Sad. Can we at least use rems, or is stripe payment also px?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies, clarification on the note - we had set the Stripe Payment Element to have a base font-size of 16px.

It looks like the Element does its own calculations from the base font size, so that its labels and error message use 15px (.93rem).

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the Stripe Appearance API, it might be possible to set the Stripe Elements sizes. https://docs.stripe.com/elements/appearance-api

{hasFullNameError && (
<Form.Message asChild>
<Localized id="next-payment-validate-name-error">
<p className="text-[15px] mt-1 text-alert-red" role="alert">
Copy link
Contributor

Choose a reason for hiding this comment

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

Same Q as above, re: font-size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See above for reasoning.

id="next-payment-confirm-with-legal-links-static-3"
elems={{
termsOfServiceLink: (
<LinkExternal
Copy link
Contributor

Choose a reason for hiding this comment

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

I think all these 2-4 <LinkExternal> components will end up having the same default data-testid prop, if that's an issue. 🤷

'data-testid': testid = 'link-external',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, thanks Peter!

@pdehaan pdehaan requested a review from a team June 4, 2024 14:58
Copy link
Contributor

@StaberindeZA StaberindeZA left a comment

Choose a reason for hiding this comment

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

I've left a few comments. I appended the comments with either "Clarification question", where I thought it might be worth while having a discussion, or "Change required" where it seems a change is necessary.

@@ -19,5 +19,5 @@
"src/**/*.spec.jsx",
"src/**/*.test.jsx"
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx", "../../shared/react/src/components/LinkExternal.tsx"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Change required. This should be removed. The payments-ui lib shouldn't be responsible for building components from shared-react

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed!

{!isPaymentElementLoading && (
<Form.Submit asChild>
<Localized id="next-new-user-submit">
<PrimaryButton
Copy link
Contributor

Choose a reason for hiding this comment

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

Change required. The submit button is clickable, even during the disabled state, when the checkbox has not been selected yet. The rest of the disabled area has a no-cursor icon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed an update for all the other changes - working on this one now.

@@ -58,6 +58,7 @@
"@fxa/shared/notifier": ["libs/shared/notifier/src/index.ts"],
"@fxa/shared/otp": ["libs/shared/otp/src/index.ts"],
"@fxa/shared/pem-jwk": ["libs/shared/pem-jwk/src/index.ts"],
"@fxa/shared/react/*": ["libs/shared/react/src/*"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Change required. Is this the alias that was generated by the nx generator? Why is it different from the typescript libraries?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I updated it to match shared-assets. I'll revert.

@xlisachan xlisachan force-pushed the FXA-9708 branch 2 times, most recently from 8a36b05 to 1351176 Compare June 4, 2024 22:25
Comment on lines 232 to 236
className={
formEnabled
? ''
: 'cursor-not-allowed relative focus:border-blue-400 focus:outline-none focus:shadow-input-blue-focus after:absolute after:content-[""] after:top-0 after:left-0 after:w-full after:h-full after:bg-white after:opacity-50 after:z-10'
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be necessary. The

creating the disabled layer encapsulates the button, so the cursor-not-allowed should also apply to the button.

I had a look at SP2, and it looks like the PrimaryButton is missing class z-[5], which we can probably replace with z-10. Adding that should work. (Note, this can be added to the PrimaryButton component directly)

{!isPaymentElementLoading && (
<Form.Submit asChild>
<Localized id="next-new-user-submit">
<div
Copy link
Contributor

Choose a reason for hiding this comment

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

This is missing the mt-14 which adds a bit of space between the checkbox and the Enter your card information.

Copy link
Contributor

@StaberindeZA StaberindeZA left a comment

Choose a reason for hiding this comment

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

lgtm, ty!

@xlisachan xlisachan merged commit 18e5d17 into main Jun 5, 2024
23 checks passed
@xlisachan xlisachan deleted the FXA-9708 branch June 5, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants