-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to optional "select" fields #783
Comments
Hello @nickfla1-mxm, I think adding an |
I agree, selects could have any data type as a value, though you could achieve the same with a string/numeric index an a mapping on the component side, the value stored in the data wouldn't be the exact value |
Hm does the following not already work? Puck should respect the optional typing. type Props = {
MyComponent: {
fruit?: 'apple' | 'banana' // Make optional with `?`
}
}
const conf: Config<Props> = {
components: {
MyComponent: {
fields: {
fruit: {
type: "select",
options: [
{ label: '', value: undefined }, // Should work because `fruit` is optional
{ label: 'Apple', value: 'apple' },
{ label: 'Banana', value: 'banana' },
]
}
}
}
}
} If not, this is likely a bug, rather than requiring a new feature |
At the time I've opened this issue you couldn't set |
Okay. I don't remember fixing this so I'm going to assume it's a bug and mark this as ready. |
Closing in favour of bug ticket here: #895 |
Currently the
select
field only supportString
,Number
orBoolean
types but in the case of optional fields forcing the user to select a value can be counter-intuitive.Given the following example:
if
mySelect
represents an optional value we could eitheror (cleaner in my opinion)
I am available to contribute directly to this feature if approved!
The text was updated successfully, but these errors were encountered: