Skip to content

Allow a custom option slot for #value when isMulti is set #128

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

Closed
rudokemper opened this issue Oct 7, 2024 · 2 comments
Closed

Allow a custom option slot for #value when isMulti is set #128

rudokemper opened this issue Oct 7, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@rudokemper
Copy link
Contributor

As far as I can tell, a custom option slot for #value does not render anything when isMulti is true. That is to say, the following code will not template selected options any differently:

<VueSelect
  :is-multi="true"
  :options="options"
  v-model="values"
>
  <template #value="{ option }">
    {{ option.label }} (selected)
  </template>
  <template #option="{ option }">
    {{ option.label }}
  </template>
</VueSelect>

It would be nice to have this. vue-select permitted this with the v-slot:selected-option parameter, which I used to style my multiple select dropdowns like this:

image

If you agree that this is a nice feature to have, I can take a shot at adding this, unless you prefer to take it on 🙂

@TotomInc
Copy link
Owner

TotomInc commented Oct 8, 2024

That's a nice catch @rudokemper, you're right the #value slot isn't used when :is-multi="true".

I believe we can introduce a new slot called #tag. This new slot should replace these lines. It should also allow access to the following values:

  • option: the option object of the tag
  • removeOption(): function to remove the tag from the selected values

If you have some time to work on this, a pull-request would be awesome 🙏

Feel free to also work on the Vitepress documentation if you have the time.

Thanks!

@TotomInc
Copy link
Owner

Added in v0.7.0: https://vue3-select-component.vercel.app/slots.html#tag

Thanks for your help! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants