Skip to content

fix: Select and shadcn FieldWrapper component#191

Open
adityacodepublic wants to merge 6 commits into
vantezzen:mainfrom
adityacodepublic:shadcn-updates
Open

fix: Select and shadcn FieldWrapper component#191
adityacodepublic wants to merge 6 commits into
vantezzen:mainfrom
adityacodepublic:shadcn-updates

Conversation

@adityacodepublic

Copy link
Copy Markdown
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

vercel Bot commented Aug 17, 2025

Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
Contributor Author

So should I update Ant and MUI to use key ?

@vantezzen

Copy link
Copy Markdown
Owner

Yes that would be good to have full consistency!

@changeset-bot

changeset-bot Bot commented Aug 18, 2025

Copy link
Copy Markdown

⚠️ 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

adityacodepublic commented Aug 18, 2025

Copy link
Copy Markdown
Contributor Author

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

adityacodepublic commented Aug 19, 2025

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

adityacodepublic commented Aug 24, 2025

Copy link
Copy Markdown
Contributor Author

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,
or if enum have same key and value the validation would pass eg. Basketball = "Basketball"

So, I've fixed it and 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

Copy link
Copy Markdown
Contributor Author

also fixes #190
@vantezzen

@adityacodepublic

Copy link
Copy Markdown
Contributor Author

Hi @vantezzen, any plans to move Autoform out of WIP ? Is there anything I can do to help ?

@adityacodepublic

Copy link
Copy Markdown
Contributor Author

Hi @vantezzen
Please review the changes and let me know if there are any corrections or improvements needed.

@adityacodepublic

Copy link
Copy Markdown
Contributor Author

?

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