Commit 45bcc14daaa75c84419c64a91ca964bed8581264
1 parent
7f63e58c
prevent calling remote method on query reset to selected
Showing
1 changed file
with
7 additions
and
2 deletions
Show diff stats
src/components/select/select.vue
... | ... | @@ -203,6 +203,7 @@ |
203 | 203 | caretPosition: -1, |
204 | 204 | lastRemoteQuery: '', |
205 | 205 | hasExpectedValue: false, |
206 | + preventRemoteCall: false, | |
206 | 207 | }; |
207 | 208 | }, |
208 | 209 | computed: { |
... | ... | @@ -558,7 +559,8 @@ |
558 | 559 | this.$emit('on-query-change', query); |
559 | 560 | const {remoteMethod, lastRemoteQuery} = this; |
560 | 561 | const hasValidQuery = query !== '' && (query !== lastRemoteQuery || !lastRemoteQuery); |
561 | - const shouldCallRemoteMethod = remoteMethod && hasValidQuery; | |
562 | + const shouldCallRemoteMethod = remoteMethod && hasValidQuery && !this.preventRemoteCall; | |
563 | + this.preventRemoteCall = false; // remove the flag | |
562 | 564 | |
563 | 565 | if (shouldCallRemoteMethod){ |
564 | 566 | this.focusIndex = -1; |
... | ... | @@ -586,7 +588,10 @@ |
586 | 588 | const [selectedOption] = this.values; |
587 | 589 | if (selectedOption && this.filterable && !this.multiple && !focused){ |
588 | 590 | const selectedLabel = selectedOption.label || selectedOption.value; |
589 | - if (this.query !== selectedLabel) this.query = selectedLabel; | |
591 | + if (this.query !== selectedLabel) { | |
592 | + this.preventRemoteCall = true; | |
593 | + this.query = selectedLabel; | |
594 | + } | |
590 | 595 | } |
591 | 596 | }, |
592 | 597 | focusIndex(index){ | ... | ... |