Commit 5266c9054b6a85ea1b86372bde592c23933c4b13
1 parent
52cfcd66
Trim label so we can compare and use label better
Showing
1 changed file
with
6 additions
and
4 deletions
Show diff stats
src/components/select/select.vue
@@ -266,7 +266,9 @@ | @@ -266,7 +266,9 @@ | ||
266 | }, | 266 | }, |
267 | queryStringMatchesSelectedOption(){ | 267 | queryStringMatchesSelectedOption(){ |
268 | const selectedOptions = this.values[0]; | 268 | const selectedOptions = this.values[0]; |
269 | - return selectedOptions && !this.multiple && this.unchangedQuery && this.query === selectedOptions.label; | 269 | + if (!selectedOptions) return false; |
270 | + const [query, label] = [this.query, selectedOptions.label].map(str => (str || '').trim()); | ||
271 | + return !this.multiple && this.unchangedQuery && query === label; | ||
270 | }, | 272 | }, |
271 | localeNotFoundText () { | 273 | localeNotFoundText () { |
272 | if (typeof this.notFoundText === 'undefined') { | 274 | if (typeof this.notFoundText === 'undefined') { |
@@ -438,7 +440,7 @@ | @@ -438,7 +440,7 @@ | ||
438 | const label = propsData.label || ''; | 440 | const label = propsData.label || ''; |
439 | const textContent = elm && elm.textContent || ''; | 441 | const textContent = elm && elm.textContent || ''; |
440 | const stringValues = JSON.stringify([value, label, textContent]); | 442 | const stringValues = JSON.stringify([value, label, textContent]); |
441 | - const query = this.query.toLowerCase(); | 443 | + const query = this.query.toLowerCase().trim(); |
442 | return stringValues.toLowerCase().includes(query); | 444 | return stringValues.toLowerCase().includes(query); |
443 | }, | 445 | }, |
444 | 446 | ||
@@ -564,7 +566,7 @@ | @@ -564,7 +566,7 @@ | ||
564 | 566 | ||
565 | this.isFocused = true; // so we put back focus after clicking with mouse on option elements | 567 | this.isFocused = true; // so we put back focus after clicking with mouse on option elements |
566 | } else { | 568 | } else { |
567 | - this.query = option.label; | 569 | + this.query = String(option.label).trim(); |
568 | this.values = [option]; | 570 | this.values = [option]; |
569 | this.lastRemoteQuery = ''; | 571 | this.lastRemoteQuery = ''; |
570 | this.hideMenu(); | 572 | this.hideMenu(); |
@@ -652,7 +654,7 @@ | @@ -652,7 +654,7 @@ | ||
652 | // restore query value in filterable single selects | 654 | // restore query value in filterable single selects |
653 | const [selectedOption] = this.values; | 655 | const [selectedOption] = this.values; |
654 | if (selectedOption && this.filterable && !this.multiple && !focused){ | 656 | if (selectedOption && this.filterable && !this.multiple && !focused){ |
655 | - const selectedLabel = selectedOption.label || selectedOption.value; | 657 | + const selectedLabel = String(selectedOption.label || selectedOption.value).trim(); |
656 | if (selectedLabel && this.query !== selectedLabel) { | 658 | if (selectedLabel && this.query !== selectedLabel) { |
657 | this.preventRemoteCall = true; | 659 | this.preventRemoteCall = true; |
658 | this.query = selectedLabel; | 660 | this.query = selectedLabel; |