riophae / vue-treeselect

A multi-select component with nested options support for Vue.js
https://vue-treeselect.js.org/
MIT License
2.91k stars 509 forks source link

re-setting / clearing selected value does not work #483

Closed qury closed 2 years ago

qury commented 2 years ago

Hi,

I'm struggling to find a solution to clear the selected value from treeselect.

Scenario: I have a treeselect that uses v-model. I want to "clear" the selection using a method not the x button but re-setting the v-model value to these: null or '' or undefined or [] does not work. The previously selected item is still displayed.

Is there a way to programmatically re-set or clear the treeselect? (exmple usecase where the value is bound to vuex state and it changes).

TitanFighter commented 2 years ago

Show your code via codesandbox.io or other service.

SevnaSW commented 2 years ago

@qury Did you solve this after?

qury commented 2 years ago

@qury Did you solve this after?

Yes.I have put a key on the component and increment it when i want to clear the values. This forces the component to re-render.

Maybe there us a better way, but this worked for me.