Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Clearing a completed result leaves stale result-mode state, causing Backspace to insert 0 into the blank entry and a subsequent square root to ignore the saved result.
1 open issue
What changed in this PR
This PR addresses #95 by updating the calculator’s existing ⌫ control and routing keyboard Backspace through the same handler.
Changes:
- Delete entry characters to blank and reset displayed results to zero while preserving calculation state.
- Move the accessible ⌫ button next to
0. - Add 61 regression tests, update keyboard assertions, and align related documentation.
| File | Description |
|---|---|
tests/backspace.test.js |
Adds state-transition, keyboard, and button-placement tests. |
test/keyboard.test.js |
Updates Backspace routing and focus expectations. |
script.js |
Revises deletion behavior and maps Backspace to ⌫. |
README.md |
Updates controls, shortcuts, and layout documentation. |
index.html |
Moves the existing ⌫ button beside 0. |
docs/TEST-SWEEP.md |
Records the Backspace test matrix and validation results. |
docs/KEYBOARD.md |
Documents shared keyboard and button behavior. |
docs/ARCHITECTURE.md |
Updates layout and keyboard-routing descriptions. |
docs/ACCESSIBILITY.md |
Updates Backspace shortcut guidance. |
Review effort: Balanced
| const entry = this.currentOperand.toString() | ||
| if (entry === '' || entry === '-' || entry === '-0') return | ||
| if (entry.length === 1) { | ||
| if (this.isResult) { |
Collaborator
Author
|
Verified the existing issue implementation at 14f947a in an isolated worktree: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #95
Summary
tests/backspace.test.js, update the existing keyboard routing assertions, and record the cell-to-test matrix indocs/TEST-SWEEP.md.Regression fixes proved by the sweep
The baseline already had a ⌫ button and mapped Backspace to DEL, unlike the issue's initial description. Tests exposed that ⌫ stopped at zero instead of deleting to empty, truncated results instead of resetting them, and was not next to 0. The minimal implementation updates only backspace behavior, key routing, and button placement; DEL and square root remain unchanged.
Validation
Tests were added before implementation; baseline was 359 passing tests. New tests reproduced the mismatches before the fix.
node --test tests/backspace.test.js: 61 pass, 0 failnode --test: 420 pass, 0 failgit diff --check: cleanNo dependencies added; tests use real markup/event handlers with a lightweight DOM stub, no browser required.