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 |
There was a problem hiding this comment.
Fixed — removed unused defaultIsEqual. Good catch.
1160bd7
|
Published in |
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