From c3304bce349cb652f68b56a68360bbe3fd902f2b Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Fri, 11 May 2018 08:45:14 +0200 Subject: [PATCH] correct unchangedQuery and queryStringMatchesSelectedOption logic and --- src/components/select/select-head.vue | 1 + src/components/select/select.vue | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/select/select-head.vue b/src/components/select/select-head.vue index 3d54d643..4165e5f5 100644 --- a/src/components/select/select-head.vue +++ b/src/components/select/select-head.vue @@ -182,6 +182,7 @@ // #982 if (typeof value === 'undefined' || value === '' || value === null) this.query = ''; else this.query = value.label; + this.$nextTick(() => this.preventRemoteCall = false); // this should be after the query change setter above }, query (val) { if (this.preventRemoteCall) { diff --git a/src/components/select/select.vue b/src/components/select/select.vue index a202cf03..0cf9a001 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -266,7 +266,7 @@ }, queryStringMatchesSelectedOption(){ const selectedOptions = this.values[0]; - return selectedOptions && !this.multiple && this.unchangedQuery && this.query === selectedOptions.value; + return selectedOptions && !this.multiple && this.unchangedQuery && this.query === selectedOptions.label; }, localeNotFoundText () { if (typeof this.notFoundText === 'undefined') { @@ -391,6 +391,7 @@ }, clearSingleSelect(){ // PUBLIC API this.$emit('on-clear'); + this.hideMenu(); if (this.clearable) this.values = []; }, getOptionData(value){ @@ -437,7 +438,8 @@ const label = propsData.label || ''; const textContent = elm && elm.textContent || ''; const stringValues = JSON.stringify([value, label, textContent]); - return stringValues.toLowerCase().includes(this.query.toLowerCase()); + const query = this.query.toLowerCase(); + return stringValues.toLowerCase().includes(query); }, toggleMenu (e, force) { @@ -563,7 +565,7 @@ this.isFocused = true; // so we put back focus after clicking with mouse on option elements } else { - this.query = option.value; + this.query = option.label; this.values = [option]; this.lastRemoteQuery = ''; this.hideMenu(); @@ -576,9 +578,9 @@ this.broadcast('Drop', 'on-update-popper'); }, onQueryChange(query) { - this.unchangedQuery = false; + if (query.length > 0 && query !== this.query) this.visible = true; this.query = query; - if (this.query.length > 0) this.visible = true; + this.unchangedQuery = this.visible; }, toggleHeaderFocus({type}){ if (this.disabled) {