Skip to content

Commit 37e0a7c

Browse files
authored
fix(core): TRAC-275 align formField.required with field.required for checkbox-group (#3005)
* fix(core): align formField.required with field.required for checkbox-group * chore: fix prettier formatting * refactor: use if/else for checkbox-group schema per review
1 parent 24cc310 commit 37e0a7c

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@bigcommerce/catalyst-core": patch
3+
---
4+
5+
Fix `formField.required` mismatch for `checkbox-group` fields in `DynamicForm`. The schema branch was missing `.optional()` for non-required checkbox groups.
6+

core/vibes/soul/form/dynamic-form/schema.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ function getFieldSchema(
302302
case 'checkbox-group':
303303
fieldSchema = z.string().array();
304304

305-
if (field.required === true) fieldSchema = fieldSchema.nonempty();
305+
if (field.required === true) {
306+
fieldSchema = fieldSchema.nonempty();
307+
} else {
308+
fieldSchema = fieldSchema.optional();
309+
}
306310

307311
break;
308312

0 commit comments

Comments
 (0)