Fix #974: Use parse instead of format in checkbox/radio checked logic#1074
Merged
Fix #974: Use parse instead of format in checkbox/radio checked logic#1074
Conversation
The bug: getInputChecked() used format() to transform the value before comparing to _value. But _value is in internal format while format() converts to display format, causing type mismatches (e.g. string "10" vs number 10). Fix: Use parse() instead of format() in checkbox/radio checked logic. This compares the parsed internal value with the raw _value attribute. Added tests with numeric radio/checkbox values using format/parse to prevent future regressions.
📝 WalkthroughWalkthroughUpdated field-checked logic to use Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
erikras
requested changes
Feb 13, 2026
src/useField.ts
Outdated
Contributor
Author
There was a problem hiding this comment.
Fixed — removed unused defaultIsEqual. Good catch.
1160bd7
erikras
approved these changes
Feb 13, 2026
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.
Fixes #974
Problem
In
useField.ts,getInputChecked()usesformat(value, name)to transform the value before comparing to_value. But_valueis in internal format whileformatconverts to display format. This causes type mismatches (e.g. comparing string "10" to number 10 fails strict equality).Solution
Use
parseinstead offormatingetInputChecked(). This compares the parsed internal value with the raw_valueattribute, ensuring type consistency.Tests
Added tests with numeric radio/checkbox values using format/parse to verify the fix and prevent future regressions.
Summary by CodeRabbit
Tests
Bug Fixes