auto-form icon indicating copy to clipboard operation
auto-form copied to clipboard

fix: Select and shadcn FieldWrapper component

Open adityacodepublic opened this issue 5 months ago • 9 comments

Fixes: #190 (dual error in array field), #180, #182, and other select-related issues.

One thing I’d like to confirm — should the <SelectItem> value remain as key (as before), or should we use the label ? Ant and MUI use the label as the value, whereas Chakra, Mantine, and shadcn use the key.

<SelectItem key={key} value={key}>
  {label}
</SelectItem>

adityacodepublic avatar Aug 17 '25 02:08 adityacodepublic

@adityacodepublic is attempting to deploy a commit to the vantezzen Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Aug 17 '25 02:08 vercel[bot]

I think maybe using the key makes more sense? I feel like label sounds more like a user-facing/display-only property than a unique way to identify values? And IIRC zod is also more focused on that.

vantezzen avatar Aug 18 '25 09:08 vantezzen

So should I update Ant and MUI to use key ?

adityacodepublic avatar Aug 18 '25 09:08 adityacodepublic

Yes that would be good to have full consistency!

vantezzen avatar Aug 18 '25 13:08 vantezzen

⚠️ No Changeset found

Latest commit: 6b68e975ebed14f59fd522a29d6504f7263095f8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Aug 18 '25 15:08 changeset-bot[bot]

But for


enum Sports {
  Football = "Football/Soccer",
  Basketball = "Basketball",
  Baseball = "Baseball",
  Hockey = "Hockey (Ice)",
  None = "I don't like sports",
}

key will be available only with zod schemas.

for yup and joi schemas the key and label will be same, as they don't provide keys of enum in their schema.

adityacodepublic avatar Aug 18 '25 16:08 adityacodepublic

Depending on the use case, the user may require either the label or the id (key) as the selected value from the form

there should be a way to provide label and id (key) in the options ?

adityacodepublic avatar Aug 19 '25 03:08 adityacodepublic

Oh I didn't know that about joi and yup! That's difficult, I think at the end zod expects the key as the value otherwise the schema is invalid, right?

vantezzen avatar Aug 20 '25 15:08 vantezzen

Zod, Yup, and Joi all expect enum values (ie: labels) as valid inputs for schema validation.

Previously, Select tests passed because Select, enums weren’t used in basic.cy tests, and if enum have same key and value the validation would pass eg. Basketball = "Basketball"

So, I've updated Shadcn and Mantine SelectField to use the enum values (ie: labels) (all SelectField components use labels) Now added tests for all Select components using a TypeScript enum

enum Sports { Football = "Football/Soccer", Basketball = "Basketball", Baseball = "Baseball", Hockey = "Hockey (Ice)", None = "I don't like sports", }

adityacodepublic avatar Aug 24 '25 15:08 adityacodepublic