From 5266c9054b6a85ea1b86372bde592c23933c4b13 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Fri, 11 May 2018 10:52:58 +0200 Subject: [PATCH] Trim label so we can compare and use label better --- src/components/select/select.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 1872894..c79bb52 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -266,7 +266,9 @@ }, queryStringMatchesSelectedOption(){ const selectedOptions = this.values[0]; - return selectedOptions && !this.multiple && this.unchangedQuery && this.query === selectedOptions.label; + if (!selectedOptions) return false; + const [query, label] = [this.query, selectedOptions.label].map(str => (str || '').trim()); + return !this.multiple && this.unchangedQuery && query === label; }, localeNotFoundText () { if (typeof this.notFoundText === 'undefined') { @@ -438,7 +440,7 @@ const label = propsData.label || ''; const textContent = elm && elm.textContent || ''; const stringValues = JSON.stringify([value, label, textContent]); - const query = this.query.toLowerCase(); + const query = this.query.toLowerCase().trim(); return stringValues.toLowerCase().includes(query); }, @@ -564,7 +566,7 @@ this.isFocused = true; // so we put back focus after clicking with mouse on option elements } else { - this.query = option.label; + this.query = String(option.label).trim(); this.values = [option]; this.lastRemoteQuery = ''; this.hideMenu(); @@ -652,7 +654,7 @@ // restore query value in filterable single selects const [selectedOption] = this.values; if (selectedOption && this.filterable && !this.multiple && !focused){ - const selectedLabel = selectedOption.label || selectedOption.value; + const selectedLabel = String(selectedOption.label || selectedOption.value).trim(); if (selectedLabel && this.query !== selectedLabel) { this.preventRemoteCall = true; this.query = selectedLabel; -- libgit2 0.21.4