Skip to content

v0.4.1 — Qty input fix

Choose a tag to compare

@janayuv janayuv released this 21 May 03:29
· 73 commits to master since this release

Bug fix

Qty field no longer resets on every digit typed in the invoice form.

Root causes fixed

  • watch() calls in InvoiceNew.tsx subscribed the entire form component to re-render on every child field change, including each keystroke in the Qty input. Replaced with useWatch() so only the four watched fields (currency, transport_mode, incoterm, show_sa_number) trigger a parent re-render.
  • The Qty <Input> was a controlled input (value={String(qty)}) tied to the parsed float from useWatch. Intermediate values like "1." were immediately overwritten by the form store value. Replaced with register(..., { valueAsNumber: true }), matching the existing unit_price pattern — the browser now owns the display state.

Unchanged

  • Total-amount computation (useWatch + useEffect in GoodsRow)
  • Footer totals, Zod validation, submit payload shape
  • All other invoice fields, backend logic, and PDF/Excel exports