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

@W-12627117@ - [Accessibility][Checkout Page][Toggle Cart Actions] Adding aria-label for action buttons #1906

Merged
merged 10 commits into from
Jul 18, 2024

Conversation

shethj
Copy link
Collaborator

@shethj shethj commented Jul 16, 2024

Description

[Issue] There are multiple buttons that have the same label of 'Edit' [User Impact] Screen reader users will have difficulty distinguishing between these buttons.

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • Added action-specific Labels on Toggle Card
  • Added aria-label to button on toggle card

How to Test-Drive This PR

  • Run npm start
  • Navigate to localhost:3000
  • Add an item to cart
  • Checkout item
  • Fill in all information on checkout page
  • Verify Edit labels are as shown in the screenshot
  • Confirm edit labels are read out correctly using screen readers
Screenshot 2024-07-16 at 12 23 26 PM

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@shethj shethj requested a review from a team as a code owner July 16, 2024 16:25
@@ -152,6 +152,12 @@ const Payment = () => {
}
disabled={appliedPayment == null}
onEdit={() => goToStep(STEPS.PAYMENT)}
editLabel={
<FormattedMessage
Copy link
Collaborator

Choose a reason for hiding this comment

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

A React Component is passed, but it is used as a component, which is kinda odd. Why not use intl.formatMessage and have the ToggleCard consumes as is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh yeah. Makes sense. Replaced it with formatMessage({...}). Thanks!

@@ -34,6 +34,15 @@ export const ToggleCard = ({
children,
...props
}) => {
let editButtonAriaLabel = 'Edit'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This string will need to have translation attached to it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replaced it with formatMessage

editLabel?.type?.displayName === 'MemoizedFormattedMessage'
) {
editButtonAriaLabel = editLabel?.props.defaultMessage[0].value
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not necessary to have this if logic here, any reason we can't consume editLabel prop directly into the component as

// ToggleCart.jsx
...
  <Button
       variant="link"
       size="sm"
        onClick={onEdit}
       aria-label={editLabel}
/>
...


// Payment Component
<ToggleCart  editLabel={intl.formattedMessage({id: 'Payment Edit', defaultMessage: "Payment Edit"})
  

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replaced logic passing formatMessage() to editLabel

variant="link"
size="sm"
onClick={onEdit}
aria-label={editButtonAriaLabel}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a test for this please?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added tests

Copy link
Collaborator

@joeluong-sfcc joeluong-sfcc left a comment

Choose a reason for hiding this comment

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

Other than the small comment, LGTM

@@ -6,7 +6,7 @@
*/
import React, {useState} from 'react'
import {nanoid} from 'nanoid'
import {defineMessage, useIntl} from 'react-intl'
import {FormattedMessage, defineMessage, useIntl} from 'react-intl'
Copy link
Collaborator

Choose a reason for hiding this comment

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

FormattedMessage doesn't seemed to be used in this file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed unused import

alexvuong
alexvuong previously approved these changes Jul 17, 2024
@shethj shethj merged commit 805c97b into develop Jul 18, 2024
28 checks passed
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.

3 participants