sagalbot / vue-select

Everything you wish the HTML <select> element could do, wrapped up into a lightweight, extensible Vue component.
https://vue-select.org
MIT License
4.62k stars 1.33k forks source link

Question: how to deselect or clear selection beta 3 #1608

Closed soongsta closed 1 year ago

soongsta commented 2 years ago

Question How to deselect or clear selection in vue-select 4.0.0-beta.3

Reproduction Link https://stackblitz.com/edit/node-iquvk1?file=pages%2Findex.vue You may need to "npm run dev" in the console window

The reproduction link shows 2 ways where I am trying to call a method to clear the region field What is the proper way to do this? As both methods I have tried do not work

Cheers

tkayo commented 2 years ago

running into the same issue on my end. seems i cannot clear a selection

OjGrooms commented 2 years ago

I have the perfect example for this.

Using Vue-Select wrapped in a VueComponent, when the rest of the form values are reset to empty string values, Vue-Select will hold onto the selected value in model_value and _value. Setting the v-model to an empty { label: '', data: ''} will set a selection with an empty label string.

The consistent way I've been able to clear the selection is by setting your v-model to undefined using your stackblitz project.

Fork: https://stackblitz.com/edit/node-lkrt63?file=pages%2Findex.vue

ManuelTS commented 1 year ago

This issue persists on beta 5

sagalbot commented 1 year ago

This is how I'd do it based on the original stackblitz example.

https://stackblitz.com/edit/node-ngtd7i?file=pages/index.vue