Skip to content

fix(invoices): let the quantity field actually clear instead of snapping back to 0 - #73

Merged
tyrellcurry merged 1 commit into
developfrom
fix/qty-input-backspace
Aug 8, 2026
Merged

tyrellcurry merged 1 commit into
developfrom
fix/qty-input-backspace

Conversation

@tyrellcurry

Copy link
Copy Markdown
Owner

Backspacing the quantity field to empty didn't clear it, it snapped straight back to a literal "0". Not something inherent to number inputs generally, this specific one just never got the same treatment the price field already has.

Root cause: the change handler does Number(event.target.value), and Number('') is 0, not NaN. So clearing the field sets state to 0, and the controlled value={item.quantity} renders that 0 right back into the input, defeating the clear.

Same one-line fix already used for price: value={item.quantity || ''}, blank displays when the value is falsy, typing still works normally.

Added an e2e test exercising the actual browser behavior (fill an item, clear the quantity field, assert it's genuinely empty), not just a unit-level check, since this bug only shows up through the real controlled-input render cycle.

Copilot AI lite review requested due to automatic review settings August 8, 2026 02:59
@tyrellcurry tyrellcurry self-assigned this Aug 8, 2026
@vercel

vercel Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
invoice-app Ready Ready Preview Aug 8, 2026 2:59am

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the invoice line-item quantity controlled input so clearing the field (backspacing to empty) doesn’t immediately re-render as a literal 0, matching the existing UX behavior for the price field. It also adds an end-to-end test to ensure the browser-level controlled-input behavior stays correct.

Changes:

  • Update the quantity <input type="number"> to render '' when item.quantity is falsy, preventing the “snap back to 0” behavior when cleared.
  • Add a Playwright e2e test that clears the quantity field and asserts it remains empty.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
frontend/src/features/invoices/components/invoice-form-drawer/invoice-form-drawer.tsx Adjusts the controlled quantity input’s value to allow the field to visually clear instead of re-rendering 0.
frontend/e2e/create-invoice.spec.ts Adds an e2e regression test covering clearing the quantity field and confirming it stays empty.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tyrellcurry
tyrellcurry merged commit d79c8af into develop Aug 8, 2026
10 checks passed
@tyrellcurry
tyrellcurry deleted the fix/qty-input-backspace branch August 8, 2026 03:14

This branch was successfully deployed

1 active deployment
Preview — 1575656c Deployed Aug 8, 2026 by vercel[bot]
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