Skip to content

Conversation

adityacodepublic
Copy link
Contributor

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>

@vercel
Copy link

vercel bot commented Aug 17, 2025

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

A member of the Team first needs to authorize it.

@vantezzen
Copy link
Owner

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.

@adityacodepublic
Copy link
Contributor Author

So should I update Ant and MUI to use key ?

@vantezzen
Copy link
Owner

Yes that would be good to have full consistency!

@changeset-bot
Copy link

changeset-bot bot commented Aug 18, 2025

⚠️ No Changeset found

Latest commit: 6b68e97

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

@adityacodepublic adityacodepublic changed the title fix: shadcn Select and FieldWrapper component fix: Select and shadcn FieldWrapper component Aug 18, 2025
@adityacodepublic
Copy link
Contributor Author

adityacodepublic commented Aug 18, 2025

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
Copy link
Contributor Author

adityacodepublic commented Aug 19, 2025

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 ?

@vantezzen
Copy link
Owner

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?

@adityacodepublic
Copy link
Contributor Author

adityacodepublic commented Aug 24, 2025

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",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error shown in a wrong field in Zod 4 Array schema

2 participants