vue-select: option:deselected and option:deselecting are not getting emitted

Describe the bug

Hello there! I’ve installed the latest version of vue-select (3.11.2, but also tried 3.11.1), and it seems like the two deselection events do not get emitted.

To Reproduce

<vue-select
    :searchable="false"
    :options="options"
    :value="value"
    :reduce="option => option.value"
    @input="$emit('input', $event)"
    @option:selected="$emit('select')"
    @option:deselected="$emit('select')" />

Expected behavior option:deselected should get fired. As you can see in my screenshot, the two selecting and selected events do get fired, but not deselection ones (corresponding to the last input event you see). I’ve also tried with option:deselecting, and it also doesn’t work.

Screenshots image

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 6
  • Comments: 15

Commits related to this issue

Most upvoted comments

Using @update:modelValue worked for me. That seems to fire both when selecting and deselecting items.

After a small investigation, the problems comes from the fact that clicking on the “clear selection” button doesn’t call the same method (clearSelection()) as when you deselect an option in a multiple select (deselect()). The option:deselect(ing|ed) events get only emitted in the deselect() method, and they get passed the deselected option as parameter.

I would say that technically it’s not a bug, as “clearing selection” is not the same as “deselecting something”. But if we have option:selected then I think that we must also have option:deselected.

This would mean adding two $emit in the clearSelection method, maybe with no parameter?

@input="$emit('input', $event)"

How could you explain? I am not able to handle callback of @input on single selects. I am using Vue-Select 4.0.0-beta.2