Skip to content

Fix quantity input +/- buttons decrementing under screen readers - #3976

Open
ZebaAfiaShama wants to merge 1 commit into
Shopify:mainfrom
ZebaAfiaShama:fix/quantity-input-a11y-3972
Open

Fix quantity input +/- buttons decrementing under screen readers#3976
ZebaAfiaShama wants to merge 1 commit into
Shopify:mainfrom
ZebaAfiaShama:fix/quantity-input-a11y-3972

Conversation

@ZebaAfiaShama

@ZebaAfiaShama ZebaAfiaShama commented Sep 7, 2026

Copy link
Copy Markdown

Fixes #3972 line

QuantityInput.onButtonClick (assets/global.js) used event.target.nameto determine which button was pressed. When the button is activated via a screen reader or keyboard,event.targetresolves to the visually-hidden accessible-name span inside the button (which has nonameattribute) rather than the button itself — since that span haspointer-events: autowhile the icon haspointer-events: none. Lacking a name, the check falls through to stepDown()`, so the "+" button decrements the quantity instead of incrementing it. Mouse clicks are unaffected since they hit-test to the button directly.

Fix: use event.currentTarget instead, which always refers to the element the listener is bound to (the button). This matches the pattern already used in the slider's onButtonClick in the same file.

Before / after

Before (bug — event.target.name, two occurrences):
https://prnt.sc/spD1BXBgWfL4

After (fixed — event.currentTarget.name, no remaining occurrences):
https://prnt.sc/I0n3jufAMiJe

Test plan

  • Verified both event.target.name occurrences (lines 249, 261) replaced with event.currentTarget.name
  • Confirmed the pattern matches the existing slider onButtonClick handler in the same file
  • Manual test: activate +/- buttons via screen reader/keyboard on a product page with a quantity selector

QuantityInput.onButtonClick used event.target.name to determine which
button was pressed. When activated via screen reader/keyboard, the
event target resolves to the visually-hidden accessible-name span
inside the button (which has no name attribute) rather than the
button itself, so the plus button incorrectly fell through to
stepDown(). Mouse clicks were unaffected since they hit-test to the
button directly.

Use event.currentTarget.name instead, matching the pattern already
used in the slider's onButtonClick in the same file.

Fixes Shopify#3972

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFhzTdXdDnPmBJzysuzKuD
@ZebaAfiaShama
ZebaAfiaShama force-pushed the fix/quantity-input-a11y-3972 branch from 71a9bbd to 1859ea1 Compare September 7, 2026 07:50
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.

Quantity +/- buttons decrement when activated by a screen reader (2.1.1)

1 participant