Skip to content
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

SelectMenu new options are being created as objects instead of strings #1073

Closed
potykion opened this issue Dec 6, 2023 · 1 comment · Fixed by #1080
Closed

SelectMenu new options are being created as objects instead of strings #1073

potykion opened this issue Dec 6, 2023 · 1 comment · Fixed by #1080
Labels
bug Something isn't working

Comments

@potykion
Copy link

potykion commented Dec 6, 2023

Environment

Version

^2.11.0

Reproduction

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

Steps to reproduce:

  • Create a new option in SelectMenu
  • Expecting: item.title to be string
  • Actual: item.title is object {label: string}

Description

When I init SelectMenu with searchable and creatable props and create a new item, the v-model value is set as an object {label: string} instead of a string

image

image

Additional context

No response

Logs

No response

@nickyg91
Copy link

nickyg91 commented Jan 9, 2024

I was having this same problem when I stumbled across this issue. I have started using the edge version of nuxt-ui where this is supposedly fixed, however it seems like the behavior is the same.
This stackblitz uses the edge version of nuxt-ui and demonstrates the same issue with both multiple and non-multiple scenarios. It is possible that I am not using this right as I just started using nuxt last Thursday. There is a workaround: something like this

<USelectMenu
        v-model="state.tags"
        :options="tags"
        show-create-option-when="always"
        creatable
        searchable
        multiple
        @update:model-value="onModelValueUpdated"
      >
      </USelectMenu>
function onModelValueUpdated(values: [{ label: string }]) {
  state.tags = values.map((x: { label: string }) => x.label);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants