Skip to content

fix(a11y): expose question card option state via aria-pressed (#9492) - #9507

Merged
dwu96 merged 1 commit into
mainfrom
fix/question-card-option-aria-state-9492
Sep 8, 2026
Merged

dwu96 merged 1 commit into
mainfrom
fix/question-card-option-aria-state-9492

Conversation

@NicholasRBowers

Copy link
Copy Markdown
Contributor

Problem / Motivation

The ask_question card shows answer options as buttons. When a user picks one, the card only changes the button's colors. A screen reader never hears about it: every option is announced as a plain button, with no way to tell which one is chosen (WCAG 4.1.2 Name/Role/Value). The card's fold toggle already announces its state via aria-expanded; the option buttons were the gap.

Why it matters

A screen-reader user can pick an answer and get no confirmation it is selected. On a multi-question card they cannot review what they are about to submit. The selection state exists only as pixels.

What changed (motivation → approach → change)

The option button was rendered with only key, onClick, and className, so the selected state lived in CSS classes alone.

Each option button now sets aria-pressed={isSelected}. This is the toggle-button pattern, used in both modes. It matches multiSelect exactly: each option is an independent toggle. It also stays honest for single-select, which deliberately supports click-again-to-deselect — role=radio + aria-checked would promise a control that cannot be unchecked by re-activating it, and this one can (the issue's own analysis flags this). The same fix class landed in #7495 for the chat pin toggle.

The deselect behavior itself is unchanged — the diff touches only the button's attributes and the tests.

Tests

  • New: single-select aria-pressed transitions — all options start false, picking one flips it to true, a second click on it (deselect) returns it to false.
  • New: multiSelect toggles aria-pressed independently per option; toggling one off leaves the other true.
  • Updated: the single-select-replaces-previous, multi-select, and custom-input-clears-selection tests now assert aria-pressed (the programmatic state) instead of CSS class names.
  • Kept: one className assertion pinning the selected-state visual styling.

Manual verification

N/A — unit coverage sufficient: the change is a single ARIA attribute whose true/false transitions are asserted directly in both modes.

Screenshots / video

Why no screenshot: the diff adds a non-rendering ARIA attribute; no pixel changes in any state.

Related Issues

Closes #9492

Pattern harvest

Rule candidate: review-prompt
Pattern: interactive element whose selected/active state is styled via className with no matching aria-* state attribute

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

The ask_question card's option buttons carried their selected state only in
CSS classes. A screen reader announced every option as a generic button and
could not report which one was chosen (WCAG 4.1.2 Name/Role/Value).

Each option button now sets aria-pressed={selected} in both modes.
aria-pressed matches multiSelect's independent toggles exactly, and for
single-select it keeps the intended click-again-to-deselect behavior honest:
role=radio semantics forbid unchecking by re-activation, which this control
deliberately supports. The deselect behavior is unchanged.

Tests assert the aria-pressed true/false transitions in both modes,
including the single-select deselect, replacing className-based selection
assertions; one className assertion remains to pin the visual styling.

Closes #9492
@NicholasRBowers
NicholasRBowers requested review from a team and Zedmor September 8, 2026 17:45
@NicholasRBowers

Copy link
Copy Markdown
Contributor Author

Intent: Make the ask_question card's option buttons announce their selected state to assistive technology by adding aria-pressed in both selection modes, so a screen-reader user can tell which answer is chosen.
Not a goal: Changing the click-again-to-deselect behavior, adopting radiogroup semantics, or touching EscalationCard (PR #8613).

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — ✅ PASS

UX-level review of 745a2b413a2039d92a3272f1a3dc4a3db03c45a5 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: PASS

Non-rendering ARIA-only change: option buttons now announce selected state to assistive tech honestly (aria-pressed matches the real click-again-to-deselect behavior); zero pixel or copy delta, so no screenshot owed.

[UX-REVIEWED] 745a2b4

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 745a2b413a2039d92a3272f1a3dc4a3db03c45a5 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Real WCAG 4.1.2 gap, fixed at the root with the correct ARIA pattern; the radio-semantics alternative is rejected for a stated, verifiable behavioral reason.

[DESIGN-REVIEWED] 745a2b4

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 745a2b413a2039d92a3272f1a3dc4a3db03c45a5 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 745a2b4

Verdict parsed from the review's SHA-scoped output markers for commit 745a2b413a2039d92a3272f1a3dc4a3db03c45a5.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 745a2b413a2039d92a3272f1a3dc4a3db03c45a5: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 745a2b413a2039d92a3272f1a3dc4a3db03c45a5 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All verification complete. The kept className pin exists at QuestionCard.test.tsx:74-79, the deselect-on-second-click premise is pinned by pre-existing base tests (publishes draft-active … clears it on deselect, does not fold on a deselect), aria-pressed is the established convention across ~60 source files in website/src, and the fix has a linked issue plus the repo's own a11y convention in website/AGENTS.md as provenance. Every rewritten test pin is declared in the description and replaced by an equivalent programmatic assertion, with the visual pin retained once.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (4 items)

Intent: let a screen-reader user hear which answer option is selected on the ask_question card — a FIX.

  1. Each option button now announces selected/unselected state to assistive tech (aria-pressed, both modes) — justified
  2. Unselected options explicitly expose aria-pressed="false" (the !! coercion) rather than omitting the attribute — justified
  3. Three existing tests re-pinned from CSS class names to aria-pressed; one visual className pin kept — justified
  4. Two new tests pin the true/false transitions, including single-select deselect — justified

[FIRST-PRINCIPLES-REVIEWED] 745a2b4

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 745a2b413a2039d92a3272f1a3dc4a3db03c45a5 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 745a2b4

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 745a2b413a2039d92a3272f1a3dc4a3db03c45a5: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 8, 2026
@dwu96
dwu96 enabled auto-merge (squash) September 8, 2026 19:04

@dwu96 dwu96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: a11y fix exposing the option card's selected state programmatically via aria-pressed (WCAG 4.1.2) — CSS-only state was the root cause; the only non-test change is one added attribute plus a boolean coercion, no behaviour change.

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: WCAG 4.1.2 fix — option buttons in QuestionCard exposed selected state only via CSS classes, so aria-pressed is now bound to the existing isSelected value (coerced to a real boolean) and the test file switches from className assertions to aria-pressed assertions; no logic, data or trust-boundary change.

@dwu96
dwu96 merged commit 6ae7417 into main Sep 8, 2026
64 checks passed
@dwu96
dwu96 deleted the fix/question-card-option-aria-state-9492 branch September 8, 2026 19:06

@chenmingwei23 chenmingwei23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: a11y bug fix - expose selected state via aria-pressed (WCAG 4.1.2), replacing CSS-only state; 2 files, component plus its test.

@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 8, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…tdev#9492) (kirodotdev#9507)

The ask_question card's option buttons carried their selected state only in
CSS classes. A screen reader announced every option as a generic button and
could not report which one was chosen (WCAG 4.1.2 Name/Role/Value).

Each option button now sets aria-pressed={selected} in both modes.
aria-pressed matches multiSelect's independent toggles exactly, and for
single-select it keeps the intended click-again-to-deselect behavior honest:
role=radio semantics forbid unchecking by re-activation, which this control
deliberately supports. The deselect behavior is unchanged.

Tests assert the aria-pressed true/false transitions in both modes,
including the single-select deselect, replacing className-based selection
assertions; one className assertion remains to pin the visual styling.

Closes kirodotdev#9492

Co-authored-by: Nick Bowers <nrb@amazon.com>
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.

a11y: ask_question card option buttons expose no selected state

4 participants