Repository navigation
Conversation
There was a problem hiding this comment.
🟡 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
| // 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 |
| this.announcement = this.errorMessage || [ | ||
| this.previousOperandTextElement.innerText, | ||
| this.currentOperandTextElement.innerText | ||
| ].filter(Boolean).join(' ') || 'Cleared' |
|
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 |

Summary
Closes #99.
Memory stored: {total},Memory recalled: {value}, andMemory cleared.tests/aria.test.jsand document every cell indocs/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 failednode --test: 388 passed, 0 failedgit diff --check: cleanNo dependencies added. Tests exercise real handlers and count live-region DOM writes; actual screen-reader speech was not browser-tested.