From 45bcc14daaa75c84419c64a91ca964bed8581264 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Thu, 12 Apr 2018 16:45:09 +0200 Subject: [PATCH] prevent calling remote method on query reset to selected --- src/components/select/select.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 25d92bc..54eb381 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -203,6 +203,7 @@ caretPosition: -1, lastRemoteQuery: '', hasExpectedValue: false, + preventRemoteCall: false, }; }, computed: { @@ -558,7 +559,8 @@ this.$emit('on-query-change', query); const {remoteMethod, lastRemoteQuery} = this; const hasValidQuery = query !== '' && (query !== lastRemoteQuery || !lastRemoteQuery); - const shouldCallRemoteMethod = remoteMethod && hasValidQuery; + const shouldCallRemoteMethod = remoteMethod && hasValidQuery && !this.preventRemoteCall; + this.preventRemoteCall = false; // remove the flag if (shouldCallRemoteMethod){ this.focusIndex = -1; @@ -586,7 +588,10 @@ const [selectedOption] = this.values; if (selectedOption && this.filterable && !this.multiple && !focused){ const selectedLabel = selectedOption.label || selectedOption.value; - if (this.query !== selectedLabel) this.query = selectedLabel; + if (this.query !== selectedLabel) { + this.preventRemoteCall = true; + this.query = selectedLabel; + } } }, focusIndex(index){ -- libgit2 0.21.4