Select does not show my selected value #1998
Replies: 3 comments 3 replies
-
@shahryarjb did you able to solve the issue ? Facing same ! |
Beta Was this translation helpful? Give feedback.
-
@shadcn Facing this as well. Suddenly, in my app, all the Select dropdown stopped showing value in SelectTrigger. It just shows blank |
Beta Was this translation helpful? Give feedback.
-
Since you were also using const albumSchema = z.object({
album_id: z.string().min(1, "Album is required"),
});
const { control } = useForm<IAlbum>({
defaultValues: { album_id: "" },
resolver: zodResolver(albumSchema)
}); <Controller
name="album_id"
control={control}
render={({ field }) => (
<Select value={field.value} onValueChange={field.onChange}>
<SelectTrigger>
<SelectValue placeholder="Select Album" />
</SelectTrigger>
<SelectContent>
{data.map(item => (
<SelectItem key={item.id} value={String(item.id)}>
{item.title}
</SelectItem>
))}
</SelectContent>
</Select>
)}
/> |
Beta Was this translation helpful? Give feedback.
-
Hello, please see these fields, as you see the select of
shadcn
allways shows the placeholder<SelectValue placeholder="انتخاب کنید" />
, and can not able to show default value of my api, but the normal html select show the value.I have read all the topics the other suggest the value of
SelectItem
should be string, and my value is string toomy code:
I have changed the
defaultValue
tovalue
and etc.By the way, some times I changed an element in page without refresh
shadcn
select works, but if I refresh this, again you can not be able to see selected value.I am using
nextjs
last version with app router and the last version ofreact-hook-form
andzod
Thank you please help me to fix this issue
Beta Was this translation helpful? Give feedback.
All reactions