Repository navigation
fix(invoices): let the quantity field actually clear instead of snapping back to 0 - #73
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
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''whenitem.quantityis 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.
This branch was successfully deployed
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.
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.