-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Multiple select and Vuex #529
Comments
You can handle this by moving the values into a computed value. That way you can define a getter and setter and do not need to include the input event. It could look something like this. computed: {
values: {
get() {
return this.$store.getters.values;
},
set(values) {
this.$store.commit('setValue', values);
}
}
} Then the component can be defined like so |
I am having this problem as well. It appears to only be an issue when you have |
Can confirm the issue is there , and only manifests for multis. |
Strict: false is an unacceptable workaround in my case. I changed two lines to use non-mutating modifiers. It's still a stupid workaround that defeats the whole point of using vuex in the first place but whatever...:) In Select.vue: Line 829 in the select(option) method: Line 852 in the deselect(option) method: |
Closed with merge of #702. Will be in v3. |
Got one problem, when storing value of multiple select in store.
Let's say we have store like this:
and somewhere in the form.vue file:
Of course that's just a simplified example. In
Select.vue
component you have aselect
method, where you have this code:At first change, when we choose a value, everything works fine. That's because FIRST_OPTION_PICK line is executed, new array is created, nothing is mutated. However, when we pick the second value, the SECOND_OPTION_PICK is executed, which just push new value to existing array. And this operation triggers Vuex error
Error: [vuex] Do not mutate vuex store state outside mutation handlers.
The problem is probably in created method, where at the beginning we have this:
this.mutableValue = this.value
, which creates only a reference, not a copy, when the value is an array. Then in SECOND_OPTION_PICK there is array push, which mutates value array in store.Is there any way to make "values" immutable, or it is bug that needs to be fixed in vue-select package?
The text was updated successfully, but these errors were encountered: