Skip to content

Add Backspace digit delete with keyboard Backspace support - #110

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

klh merged 1 commit into
masterfrom
agent/95

Conversation

@klh

@klh klh commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Closes #95

Summary

  • Reuse the existing accessible ⌫ button rather than duplicate it, and move it next to 0.
  • Route keyboard Backspace through its click handler with the existing focus, shortcut, and editable-field guards.
  • Delete entry characters down to blank; empty entries do nothing. Reset displayed results to 0 without touching pending operations, history, memory, or saved repeat/sqrt state. Retain result mode so the next digit starts fresh.
  • Add 61 parameterized state-transition tests in tests/backspace.test.js, update the existing keyboard routing assertions, and record the cell-to-test matrix in docs/TEST-SWEEP.md.
  • Update README and the related keyboard/accessibility/layout documentation.

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 fail
  • node --test: 420 pass, 0 fail
  • git diff --check: clean

No dependencies added; tests use real markup/event handlers with a lightweight DOM stub, no browser required.

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

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

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

Comment thread script.js
const entry = this.currentOperand.toString()
if (entry === '' || entry === '-' || entry === '-0') return
if (entry.length === 1) {
if (this.isResult) {
@klh

klh commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Verified the existing issue implementation at 14f947a in an isolated worktree: node --test passes all 420 tests (0 failures), and git diff --check is clean. This PR already includes Closes #95; no duplicate PR or force-push was made.

@klh
klh merged commit f4527c2 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