Skip to content

Polish aria-live result announcements (#99) - #109

Merged
klh merged 1 commit into
masterfrom
agent/99
Nov 17, 2026
Merged

klh merged 1 commit into
masterfrom
agent/99

Conversation

@klh

@klh klh commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #99.

  • Use one dedicated, visually hidden polite/atomic live region instead of replaying the whole display and history.
  • Announce errors, AC/Escape clears, and concise memory feedback: Memory stored: {total}, Memory recalled: {value}, and Memory cleared.
  • Deduplicate identical consecutive status text, including rerenders, repeated clears/recalls, and ignored operations; preserve ordinary entry/result announcements.
  • Add a parameterized state-transition matrix in tests/aria.test.js and document every cell in docs/TEST-SWEEP.md.

Regression fixes proved by tests

The original implementation left empty clears and memory-only operations without meaningful announcements. The initial test-first sweep produced 21 failures; the fix changes only announcement behavior, not calculator arithmetic, history, or memory/clear semantics. The prior memory markup test now checks the single dedicated live region.

Validation

  • node --test tests/aria.test.js: 33 passed, 0 failed
  • node --test: 388 passed, 0 failed
  • git diff --check: clean

No dependencies added. Tests exercise real handlers and count live-region DOM writes; actual screen-reader speech was not browser-tested.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 05:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Live-region state handling can suppress new-entry announcements after memory feedback and incorrectly announce “Cleared” for ignored actions on a fresh load.

2 open issues
What changed in this PR

This PR addresses #99 by giving the calculator a dedicated live region for concise status announcements, separate from display history.

Changes:

  • Add a visually hidden, polite, atomic live region.
  • Announce errors, clears, and memory actions while suppressing duplicate status text.
  • Expand announcement transition tests and document their coverage.
File Description
tests/​memory.test.cjs Update markup assertions for the dedicated live region.
tests/​aria.test.js Add transition tests that track announcement text and duplicate writes.
styles.css Visually hide announcements while retaining accessibility.
script.js Generate concise status feedback and deduplicate live-region updates.
index.html Move live announcements out of the visual output.
docs/​TEST-SWEEP.md Document the transition matrix and reported validation results.

Review effort: Balanced

Comment thread script.js
// Keep a single live region separate from history/indicator DOM mutations.
// Retain action feedback on rerenders and no-ops; only write changed text.
const displayState = JSON.stringify([
this.errorMessage, this.currentOperand.toString(), this.previousOperand.toString(), this.operation
Comment thread script.js
this.announcement = this.errorMessage || [
this.previousOperandTextElement.innerText,
this.currentOperandTextElement.innerText
].filter(Boolean).join(' ') || 'Cleared'
@klh

klh commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Independent verification: discovered this PR already on the issue branch when publishing a parallel implementation, so I did not overwrite or force-push it. Checked out commit 86f0765 and reran node --test: all 388 tests pass; git diff --check is clean. Confirmed the dedicated polite/atomic live region, error and clear feedback, formatted memory announcements, and write-count deduplication coverage. Actual screen-reader speech was not manually tested.

@klh
klh merged commit fae2614 into master Nov 17, 2026
1 check 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.

2 participants