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-12627165@ Improve accessibility of quantity picker #1552

Merged
merged 18 commits into from
Nov 21, 2023

Conversation

wjhsf
Copy link
Contributor

@wjhsf wjhsf commented Nov 20, 2023

  1. Add ARIA labels for +/- buttons
  2. Make +/- buttons keyboard focusable
  3. Make space/enter trigger +/- buttons

(git2GUS compliant redo of #1545)

Description

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

How to Test-Drive This PR

  • Start dev server
  • View any product (e.g. http://localhost:3000/global/en-GB/product/womens-jewelry-bundleM)
  • Tab into [+]. Hit space. Hit enter. Quantity should increment each time.
  • Tab into [-]. Hit space. Hit enter. Quantity should decrement each time.
  • Turn on VoiceOver. Tab into [+] and [-] to see that it says "increment quantity" / "decrement quantity", rather than just "plus" / "minus".

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)

@wjhsf wjhsf requested a review from a team as a code owner November 20, 2023 17:18
@wjhsf wjhsf enabled auto-merge (squash) November 20, 2023 17:18
</Button>
<Input {...input} />
<Button data-testid="quantity-increment" {...inc}>
+
<FormattedMessage id="product_view.label.quantity_increment" defaultMessage="+" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need translations for these symbols?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Turn on VoiceOver. Tab into [+] and [-] to see that it says "increment quantity" / "decrement quantity", rather than just "plus" / "minus".

The interaction/functionality works fine but it keeps reading the "Missing translation" error out loud instead of the actual label.

@vmarta
Copy link
Contributor

vmarta commented Nov 21, 2023

@wjhsf Is it just me... I'm seeing the minus sign rendered like this:
Google Chrome 2023-11-21 at 12 59 14

@@ -428,10 +428,9 @@ const ProductView = forwardRef(
<Box fontWeight="bold">
<label htmlFor="quantity">
{intl.formatMessage({
defaultMessage: 'Quantity',
defaultMessage: 'Quantity:',
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL: react-intl will know to exclude the colon sign in this case.

Comment on lines 67 to 69
await user.type(input, '{shift>}{tab}') // > modifier in {shift>} means "keep key pressed"
const button = screen.getByText('&minus;')
expect(button).toHaveFocus()
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, adding tests for accessibility 👍

@wjhsf wjhsf merged commit 4cf7950 into develop Nov 21, 2023
20 checks passed
@wjhsf wjhsf deleted the wjh/keyboard-a11y-W-12627165 branch November 30, 2023 21:53
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.

None yet

4 participants