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
[Feature]: Allow more types for modelValue in Select
#772
Comments
Select
Select
I did a bit of digging on this. While setting this to I suspect the reason it's only string would be because when you get values out of |
@kylemilloy, casting the type to
However, I managed to "fix" it by wrapping the |
This is my workaround for those who are interested:
<SelectItem :value="JSON.Stringify(value)">
<slot />
</SelectItem> And <script setup lang="ts" generic="TValue">
import { SelectRoot } from 'radix-vue'
import { computed } from 'vue'
const props = defineProps<{
modelValue: TValue | undefined
}>()
const emit = defineEmits<{
'update:modelValue': [value: TValue | undefined]
}>()
const model = computed<string | undefined>({
get: () => {
return JSON.stringify(props.modelValue)
},
set: (value) => {
if (value === undefined) {
emit('update:modelValue', undefined)
return
}
emit('update:modelValue', JSON.parse(value))
},
})
</script>
<template>
<SelectRoot v-model="model" >
<slot />
</SelectRoot>
</template> |
@wouterlms This hack mostly works but you'll also want to handle the @zernonia are there any plans to expand the types for this component (and others, like Radio Group, Checkbox Group, Toggle Group)? I think it's implemented quite greatly in the Combobox component so it would probably make sense to replicate this across other components to make it consistent. |
no update on this one? |
As this is highly requested feature, and it involves breaking changes. This will be included in v2 |
thank you for this solution 🙏 it worked for me! |
is this feature will be one select component only or it will include the other components aslo ( Radio Group, Checkbox , Toggle Group) ?? |
Describe the feature
Currently, the only supported value is a string, which can be limiting. It would be beneficial to expand this functionality to accommodate additional types, akin to how it's implemented in a Combobox.
Additional information
The text was updated successfully, but these errors were encountered: