Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Invalid input preserves the existing value, while clearing emits the contractually correct null or undefined value. The change is mergeable. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
|
Friendly bump — CI green. This aligns InputNumber with native number-input behavior (keep the previous value on unparseable input, emit null when cleared). Happy to adjust the emit contract if you'd prefer different semantics. |
ac3c741 to
de69424
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
reka reports unparseable text ("." / "-") and a cleared input as the same
undefined. Committing "." on a field holding 5 emitted undefined while the
input restored its own display to 5, so the parent lost the value and the
UI disagreed with it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…type Clearing the field emitted undefined while the model type declares number | null, so a cleared input did not round-trip through a null-typed model. The optional modifier still emits undefined. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
de69424 to
6c66f9f
Compare
|
Rebased on The bug is still there on today's @benjamincanac the second commit is the behavioral half and it is split out on purpose, so it can be dropped on its own. |
🔗 Linked issue
Resolves #6743
❓ Type of change
📚 Description
First, a root-cause correction for the issue title: no
NaNis ever emitted. Committing unparseable text like.or-(Enter/blur) makes reka-ui's NumberField emitundefined— the reporter'sisNaN(v)check reads true becauseisNaN(undefined)is true, andundefinedpoisons downstream arithmetic into NaN. Reka'sapplyInputValueconflates two situations that deserve different handling: a cleared input and non-empty unparseable text both nuke the model toundefined(and destroy the previous value).Two commits, separable:
1.
fix(InputNumber): keep previous value when committing unparseable input— what the reporter asked for ("maybe just revert to the previous value instead?"), matching react-spectrum's behavior. All model updates now flow throughonUpdate()— previously the auto-forwardedupdate:modelValuehandler bypassed it entirely in non-.optionalmode (and double-emitted in.optionalmode). When the committed value isundefinedbut the input still contains text, the update is dropped; sinceNumberFieldRootruns controlled, it restores the last formatted value on its own. Verified in the added test:.+ Enter on a model of5→ no emit, input text back to5.2.
fix(InputNumber): emit null when cleared to match the declared model type— the typing-soundness half reported by @danekslama in the issue comments: the emit type isnumber | null(undefinedonly with the.optionalmodifier), but clearing leakedundefinedat runtime regardless. Clearing now emitsnull, orundefinedwith.optional(unchanged). This one is mildly behavior-visible for consumers who relied on the untypedundefined— happy to drop this commit if you'd rather keep it wrapper-compatible, the first commit stands alone.Tests cover all three paths (unparseable revert / clear →
null/ clear +.optional→undefined); existing suites and snapshots unchanged (110 tests green,vue-tscclean).Upstream note: the revert-on-unparseable behavior arguably belongs in reka-ui's
applyInputValueeventually, but the wrapper can't wait on that and needs thenullconvention regardless — no reka-ui issue exists for it yet, I can file one.📝 Checklist