nuxt / ui

A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.
https://ui.nuxt.com
MIT License
4.06k stars 518 forks source link

SelectMenu ignoring initial object values #2086

Closed ThePlay3r closed 21 hours ago

ThePlay3r commented 2 months ago

Environment


Version

Pro 1.4.1

Reproduction

https://stackblitz.com/edit/nuxt-ui-u6tm1b?file=app.vue

Description

When using a v-model prop with some initial object values (such as fetched already selected data from backend), the <USelectMenu> component doesn't show these as selected and seems to ignore them completely.

Even when selecting the same objects again, it just seems to add them to the array and disregard anything, that was there previously.

Additional context

The behaviour changes when setting the by prop. In my case, I set it to id, after which I can see the object as selected, but only in the dropdown. This also allows me to edit the data as normal. (Select/Deselect) However the button itself still shows 0 selected.

Logs

No response

NasrALdaya commented 1 month ago

It seems like the same problem as issue 2028

rdjanuar commented 3 days ago

I suggest using by when your v-model is an object or an array of objects. This is because this component currently doesn't work when comparing objectA === objectB.