Skip to content

add buffer numeric text before canonicalizing it.#10

Open
lucy-04 wants to merge 1 commit into
iTeebot:mainfrom
lucy-04:fix/Preceding-zeros-in-input-fields
Open

add buffer numeric text before canonicalizing it.#10
lucy-04 wants to merge 1 commit into
iTeebot:mainfrom
lucy-04:fix/Preceding-zeros-in-input-fields

Conversation

@lucy-04

@lucy-04 lucy-04 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

created a new Number Field that will add the numbered text to a buffer enabling number like -1 or 0.5 in the required fields

Summary by CodeRabbit

  • New Features

    • Added a reusable number input with support for decimal values, optional negatives, fallback values, and committed edits.
    • Updated delivery challans, inventory adjustments, and invoice line items to use the improved number input experience.
  • Bug Fixes

    • Improved handling of intermediate, empty, and invalid numeric entries.
    • Preserved zero-value display behavior while restoring controlled values after editing.

@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

@lucy-04 is attempting to deploy a commit to the Ateeb Ur Rehman's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a reusable NumberField with draft validation and blur fallback behavior, then adopts it for quantity and unit-price editing in delivery challans, inventory adjustments, and invoices.

Changes

Numeric input handling

Layer / File(s) Summary
NumberField contract and draft handling
src/components/ui/NumberField.tsx
Adds typed props, intermediate draft state, numeric validation, commit callbacks, fallback handling, and text-based decimal input rendering.
Editor field integrations
src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx, src/modules/inventory/InventoryModule.tsx, src/modules/invoices/CreateInvoiceModule.tsx
Uses NumberField for delivery quantities, inventory adjustments, and invoice unit prices while preserving existing state update callbacks.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • iTeebot/flow#9: Updates the same numeric input fields using shared Input buffering behavior instead of a new NumberField.

Suggested reviewers: ateebnoone

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: introducing buffered numeric text before canonicalizing values.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/ui/NumberField.tsx`:
- Around line 3-8: Update src/components/ui/NumberField.tsx at lines 3-8, 11-13,
and 36-43: omit onChange with the correct casing, capture remaining native input
props, and spread them onto the internal input while preserving text-based draft
behavior; explicitly exclude or override the unsupported type prop. Review
callers at src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx lines
446-449, src/modules/inventory/InventoryModule.tsx lines 236-241, and
src/modules/invoices/CreateInvoiceModule.tsx lines 521-524, removing
type="number" where callers require native number behavior or otherwise aligning
them with NumberField’s text input contract.
- Around line 22-23: Update the commit validation in the NumberField input
handler to use Number.isFinite(n) instead of the global isNaN check, while
retaining the existing non-empty text requirement and onCommit behavior for
valid finite numbers.

In `@src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx`:
- Around line 446-449: Update the NumberField component to forward its remaining
InputHTMLAttributes onto the underlying input element, preserving its existing
value, commit handling, and fallback behavior so caller-supplied props such as
className are applied.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f462908-ba6d-434e-9c7a-e10ac5c0ffef

📥 Commits

Reviewing files that changed from the base of the PR and between cf21bb8 and f6ae163.

📒 Files selected for processing (4)
  • src/components/ui/NumberField.tsx
  • src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx
  • src/modules/inventory/InventoryModule.tsx
  • src/modules/invoices/CreateInvoiceModule.tsx

Comment on lines +3 to +8
interface NumberFieldProps
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onchange'>{
value : number
onCommit : (n:number) => void
fallback ?: number
allowNegative ? :boolean

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== NumberField ==\n'
sed -n '1,220p' src/components/ui/NumberField.tsx

printf '\n== DeliveryChallan usage ==\n'
sed -n '430,470p' src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx

printf '\n== Inventory usage ==\n'
sed -n '220,255p' src/modules/inventory/InventoryModule.tsx

printf '\n== Invoice usage ==\n'
sed -n '500,545p' src/modules/invoices/CreateInvoiceModule.tsx

Repository: iTeebot/flow

Length of output: 9237


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== NumberField references ==\n'
rg -n "NumberField|allowNegative|fallback|onCommit|type=\"number\"|required" src/components/ui/NumberField.tsx src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx src/modules/inventory/InventoryModule.tsx src/modules/invoices/CreateInvoiceModule.tsx

Repository: iTeebot/flow

Length of output: 2746


Forward native input props from NumberField. The component drops caller-supplied props because it never captures or spreads the rest of React.InputHTMLAttributes, so required, placeholder, className, and similar attributes never reach the DOM input. type="number" is also ignored because the field is hardcoded to type="text" for draft editing.

  • src/components/ui/NumberField.tsx: fix the prop type omit to use onChange (not onchange), capture the remaining input props, and spread them onto <input />.
  • Keep the internal text-based draft behavior, but make the unsupported type prop explicit or remove it from callers that expect native number input behavior.
📍 Affects 4 files
  • src/components/ui/NumberField.tsx#L3-L8 (this comment)
  • src/components/ui/NumberField.tsx#L11-L13
  • src/components/ui/NumberField.tsx#L36-L43
  • src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx#L446-L449
  • src/modules/inventory/InventoryModule.tsx#L236-L241
  • src/modules/invoices/CreateInvoiceModule.tsx#L521-L524
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/ui/NumberField.tsx` around lines 3 - 8, Update
src/components/ui/NumberField.tsx at lines 3-8, 11-13, and 36-43: omit onChange
with the correct casing, capture remaining native input props, and spread them
onto the internal input while preserving text-based draft behavior; explicitly
exclude or override the unsupported type prop. Review callers at
src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx lines 446-449,
src/modules/inventory/InventoryModule.tsx lines 236-241, and
src/modules/invoices/CreateInvoiceModule.tsx lines 521-524, removing
type="number" where callers require native number behavior or otherwise aligning
them with NumberField’s text input contract.

Comment on lines +22 to +23
const n = Number(text)
if(text != '' && !isNaN(n)) onCommit(n);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate and inspect the file in question.
git ls-files src/components/ui/NumberField.tsx
wc -l src/components/ui/NumberField.tsx
cat -n src/components/ui/NumberField.tsx | sed -n '1,220p'

Repository: iTeebot/flow

Length of output: 1804


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find local usages of NumberField and inspect the call sites.
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
  'NumberField' src

# Also inspect the component's immediate neighbors for context if any.
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
  'onCommit\(|fallback|allowNegative|inputMode="decimal"' src/components src | sed -n '1,200p'

Repository: iTeebot/flow

Length of output: 3087


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for local call sites to understand whether Infinity would affect money/quantity flows.
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
  '<NumberField|NumberField\\s*\\(' src

# Show surrounding lines for each hit.
for f in $(rg -l --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
  '<NumberField|NumberField\\s*\\(' src); do
  echo "===== $f ====="
  cat -n "$f" | sed -n '1,240p'
done

Repository: iTeebot/flow

Length of output: 263


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Probe the number semantics that drive the bug claim.
node - <<'JS'
const samples = [
  '9'.repeat(307),
  '9'.repeat(308),
  '1e309',
  '',
  '123.45',
  '-123',
  'abc',
];
for (const s of samples) {
  const n = Number(s);
  console.log(JSON.stringify({s, n, isNaN: isNaN(n), finite: Number.isFinite(n)}));
}
JS

# Find every local reference to NumberField to understand impact.
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' 'NumberField' src

Repository: iTeebot/flow

Length of output: 1873


🏁 Script executed:

#!/bin/bash
set -euo pipefail

node - <<'JS'
for (const len of [308, 309, 310, 320]) {
  const s = '9'.repeat(len);
  const n = Number(s);
  console.log(len, String(n), Number.isFinite(n), isNaN(n));
}
JS

Repository: iTeebot/flow

Length of output: 247


Reject non-finite numeric values. Number(text) overflows to Infinity for very long digit strings, and isNaN(Infinity) still passes. That can commit non-finite values into quantities and amounts; use Number.isFinite(n) here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/ui/NumberField.tsx` around lines 22 - 23, Update the commit
validation in the NumberField input handler to use Number.isFinite(n) instead of
the global isNaN check, while retaining the existing non-empty text requirement
and onCommit behavior for valid finite numbers.

Comment on lines +446 to +449
<NumberField
value={item.quantity}
onCommit={(n) => handleSetItemQty(item.product_id, n)}
fallback={1}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the relevant files and inspect the shared component plus the caller.
git ls-files 'src/components/ui/NumberField.tsx' 'src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx'

echo
echo '--- NumberField outline ---'
ast-grep outline src/components/ui/NumberField.tsx --view expanded || true

echo
echo '--- CreateDeliveryChallanModule outline (focused) ---'
ast-grep outline src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx --view expanded | sed -n '1,220p'

echo
echo '--- NumberField source ---'
wc -l src/components/ui/NumberField.tsx
cat -n src/components/ui/NumberField.tsx

echo
echo '--- Caller lines around usage ---'
sed -n '430,470p' src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx

Repository: iTeebot/flow

Length of output: 5341


Forward native input props in NumberField
NumberField accepts InputHTMLAttributes, but the props are never spread onto the <input>, so caller-supplied attributes like className are ignored. Pass the remaining props through in src/components/ui/NumberField.tsx.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx` around lines 446
- 449, Update the NumberField component to forward its remaining
InputHTMLAttributes onto the underlying input element, preserving its existing
value, commit handling, and fallback behavior so caller-supplied props such as
className are applied.

@AteebNoOne

Copy link
Copy Markdown
Member

@lucy-04 Can you see this so i will merge the PR

Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/ui/NumberField.tsx`:
- Around line 3-8: Update src/components/ui/NumberField.tsx at lines 3-8, 11-13,
and 36-43: omit onChange with the correct casing, capture remaining native input
props, and spread them onto the internal input while preserving text-based draft
behavior; explicitly exclude or override the unsupported type prop. Review
callers at src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx lines
446-449, src/modules/inventory/InventoryModule.tsx lines 236-241, and
src/modules/invoices/CreateInvoiceModule.tsx lines 521-524, removing
type="number" where callers require native number behavior or otherwise aligning
them with NumberField’s text input contract.
- Around line 22-23: Update the commit validation in the NumberField input
handler to use Number.isFinite(n) instead of the global isNaN check, while
retaining the existing non-empty text requirement and onCommit behavior for
valid finite numbers.

In `@src/modules/deliveryChallan/CreateDeliveryChallanModule.tsx`:
- Around line 446-449: Update the NumberField component to forward its remaining
InputHTMLAttributes onto the underlying input element, preserving its existing
value, commit handling, and fallback behavior so caller-supplied props such as
className are applied.

🪄 Autofix (Beta)

ℹ️ Review info

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