Commit ab611b8
fix: radio buttons with same name handle errors correctly (#5001)
When multiple Field components share the same name (e.g. radio buttons),
only the last one would receive validation errors. This happened because
createPathState only reused existing path states for fields explicitly
typed as checkbox/radio, causing separate path states to be created when
type was not specified on the Field component.
The fix makes createPathState reuse existing path states for ALL fields
sharing the same path, not just checkbox/radio types. This ensures:
- All fields with the same name share a single PathState and its errors
- removePathState properly decrements fieldsCount for all shared fields
- Unmount logic handles array IDs for non-multiple shared fields
- Path values are only unset when the last field unmounts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 7d8cc52 commit ab611b8
File tree
4 files changed
+121
-16
lines changed- .changeset
- packages/vee-validate
- src
- tests
4 files changed
+121
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
| 389 | + | |
393 | 390 | | |
394 | 391 | | |
395 | 392 | | |
| |||
405 | 402 | | |
406 | 403 | | |
407 | 404 | | |
408 | | - | |
| 405 | + | |
409 | 406 | | |
410 | 407 | | |
411 | 408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
| 266 | + | |
266 | 267 | | |
267 | | - | |
268 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
269 | 273 | | |
270 | 274 | | |
271 | 275 | | |
| |||
280 | 284 | | |
281 | 285 | | |
282 | 286 | | |
283 | | - | |
284 | 287 | | |
285 | 288 | | |
286 | 289 | | |
| |||
576 | 579 | | |
577 | 580 | | |
578 | 581 | | |
579 | | - | |
| 582 | + | |
580 | 583 | | |
581 | 584 | | |
582 | 585 | | |
| |||
589 | 592 | | |
590 | 593 | | |
591 | 594 | | |
592 | | - | |
| 595 | + | |
593 | 596 | | |
594 | 597 | | |
595 | 598 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3182 | 3182 | | |
3183 | 3183 | | |
3184 | 3184 | | |
3185 | | - | |
3186 | | - | |
3187 | | - | |
3188 | | - | |
| 3185 | + | |
| 3186 | + | |
3189 | 3187 | | |
3190 | 3188 | | |
3191 | 3189 | | |
3192 | 3190 | | |
3193 | 3191 | | |
3194 | | - | |
| 3192 | + | |
3195 | 3193 | | |
3196 | 3194 | | |
3197 | 3195 | | |
| |||
3241 | 3239 | | |
3242 | 3240 | | |
3243 | 3241 | | |
| 3242 | + | |
| 3243 | + | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
| 3257 | + | |
| 3258 | + | |
| 3259 | + | |
| 3260 | + | |
| 3261 | + | |
| 3262 | + | |
| 3263 | + | |
| 3264 | + | |
| 3265 | + | |
| 3266 | + | |
| 3267 | + | |
| 3268 | + | |
| 3269 | + | |
| 3270 | + | |
| 3271 | + | |
| 3272 | + | |
| 3273 | + | |
| 3274 | + | |
| 3275 | + | |
| 3276 | + | |
| 3277 | + | |
| 3278 | + | |
| 3279 | + | |
| 3280 | + | |
| 3281 | + | |
| 3282 | + | |
| 3283 | + | |
| 3284 | + | |
| 3285 | + | |
| 3286 | + | |
| 3287 | + | |
| 3288 | + | |
| 3289 | + | |
| 3290 | + | |
| 3291 | + | |
| 3292 | + | |
| 3293 | + | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + | |
| 3298 | + | |
| 3299 | + | |
| 3300 | + | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
| 3315 | + | |
| 3316 | + | |
| 3317 | + | |
| 3318 | + | |
| 3319 | + | |
| 3320 | + | |
| 3321 | + | |
| 3322 | + | |
| 3323 | + | |
| 3324 | + | |
| 3325 | + | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
0 commit comments