unovue / radix-vue

Vue port of Radix UI Primitives. An open-source UI component library for building high-quality, accessible design systems and web apps.
https://radix-vue.com
MIT License
3.54k stars 216 forks source link

[Bug]: Combobox with objects removes search term/value upon selection #533

Closed mjbates7 closed 11 months ago

mjbates7 commented 11 months ago

Environment

Developement/Production OS: Windows 11
Node version: 20.0.0
Package manager: yarn@8.6.0
Radix Vue version: 4.0.0
Vue version: 3.3.7
Nuxt version: 3.8.0
Nuxt mode: universal
Nuxt target: server
CSS framework: tailwindcss@3.3.3
Client OS: Windows 11 19043.1110
Browser: Chrome 90.0.4430.212

Link to minimal reproduction

https://stackblitz.com/edit/vue-enuzxs

Steps to reproduce

  1. Start typing into the box to see selections
  2. Click on an option
  3. Value doesn't get entered into the search input and value doesn't remain so you can't see what is selected

Describe the bug

Value doesn't get entered into the search input and value doesn't remain so you can't see what is selected

Expected behavior

Expect the value to remain in the input field like when viewing the example where it just uses an array of strings

Conext & Screenshots (if applicable)

No response

MellKam commented 11 months ago

@zernonia It seems that it is not only a bug with objects. The whole combobox logic has been broken since version 1.2. I just noticed this in my app and rolled back to 1.1.3 where everything works fine. Here on https://www.shadcn-vue.com/docs/components/combobox.html it also broken, but works as expected on https://www.radix-vue.com/components/combobox.

zernonia commented 11 months ago

@mjbates7 thanks for the issue. the idea is to use searchTerm to render the input text. However we find it quite difficult to utilize. Instead, I would propose to add displayValue similar to headless/ui to render the text.

@MellKam the issue is that after the latest refactoring, ComboboxItem needs to be wrapped inside ComboboxList. I've updated the docs to mentioned that.

https://www.shadcn-vue.com/docs/components/combobox

Also an issue incase anything facing the same: https://github.com/radix-vue/shadcn-vue/issues/188

zernonia commented 11 months ago

@mjbates7 I've added displayValue as proposed above. Checkout https://www.radix-vue.com/components/combobox.html#root