Commit 45bcc14daaa75c84419c64a91ca964bed8581264

Authored by Sergio Crisostomo
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,6 +203,7 @@
203 caretPosition: -1, 203 caretPosition: -1,
204 lastRemoteQuery: '', 204 lastRemoteQuery: '',
205 hasExpectedValue: false, 205 hasExpectedValue: false,
  206 + preventRemoteCall: false,
206 }; 207 };
207 }, 208 },
208 computed: { 209 computed: {
@@ -558,7 +559,8 @@ @@ -558,7 +559,8 @@
558 this.$emit('on-query-change', query); 559 this.$emit('on-query-change', query);
559 const {remoteMethod, lastRemoteQuery} = this; 560 const {remoteMethod, lastRemoteQuery} = this;
560 const hasValidQuery = query !== '' && (query !== lastRemoteQuery || !lastRemoteQuery); 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 if (shouldCallRemoteMethod){ 565 if (shouldCallRemoteMethod){
564 this.focusIndex = -1; 566 this.focusIndex = -1;
@@ -586,7 +588,10 @@ @@ -586,7 +588,10 @@
586 const [selectedOption] = this.values; 588 const [selectedOption] = this.values;
587 if (selectedOption && this.filterable && !this.multiple && !focused){ 589 if (selectedOption && this.filterable && !this.multiple && !focused){
588 const selectedLabel = selectedOption.label || selectedOption.value; 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 focusIndex(index){ 597 focusIndex(index){