Repository navigation
Conversation
|
Verified the existing implementation for #100 and added a keyboard regression fix: Enter on the Copy control now retains native button activation instead of dispatching calculator equals. The added test checks that Enter is not prevented and does not change the result. Latest validation: |
There was a problem hiding this comment.
🟡 Changes recommended
The document-level Enter handler overrides the focused Copy button’s native activation, changing the result instead of copying it; this needs a fix and a keyboard regression test.
1 open issue
What changed in this PR
Adds session-history copying to the calculator while preserving the existing last-expression display and history reset rules.
Changes:
- Adds an initially disabled Copy button with visible keyboard focus and a brief “Copied” confirmation.
- Copies completed expressions oldest-first using the Clipboard API with a textarea fallback.
- Adds tests and documentation for formatting, reset behavior, clipboard failures, focus restoration, and confirmation timing.
| File | Description |
|---|---|
| tests/memory.test.cjs | Updates the accessible-button inventory for Copy. |
| tests/history.test.cjs | Tests session copying, fallback behavior, cleanup, and timing. |
| styles.css | Styles the history panel and Copy button focus state. |
| script.js | Records session history and implements copying and confirmation. |
| README.md | Documents copying and session lifetime. |
| index.html | Adds the disabled Copy button beside history. |
| docs/TEST-SWEEP.md | Documents the copy-history test matrix and validation results. |
Review effort: Balanced
| } | ||
| } | ||
|
|
||
| historyCopyButton?.addEventListener('click', async () => { |

Closes #100
Summary
expression = resultlines vianavigator.clipboard.writeText, falling back to a temporary selected textarea if unavailable or denied. Always remove the textarea and restore focus; never claim success if both paths fail.Tests-first sweep
Eleven new matrix tests failed before implementation (the three existing history tests passed). The matrix in
docs/TEST-SWEEP.mdmaps each transition to named tests: clipboard success/missing/rejection/throw, negative and decimal line formatting, repeat/incomplete equals, fallback failures/cleanup/focus, timers, asynchronous reset, and cross-feature state preservation. Updated the accessibility button inventory for the new text-labelled control. No unrelated production bug fixes or dependencies.Validation
node --test tests/history.test.cjs: 14 pass, 0 failnode --test: 370 pass, 0 failgit diff --check: passesTests use Node VM DOM/clipboard stubs and deterministic timers; real OS/browser clipboard permissions were not exercised.