Trim label so we can compare and use label better
This commit is contained in:
parent
52cfcd662b
commit
5266c9054b
1 changed files with 6 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue