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 | 266 | }, |
| 267 | 267 | queryStringMatchesSelectedOption(){ |
| 268 | 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 | 273 | localeNotFoundText () { |
| 272 | 274 | if (typeof this.notFoundText === 'undefined') { |
| ... | ... | @@ -438,7 +440,7 @@ |
| 438 | 440 | const label = propsData.label || ''; |
| 439 | 441 | const textContent = elm && elm.textContent || ''; |
| 440 | 442 | const stringValues = JSON.stringify([value, label, textContent]); |
| 441 | - const query = this.query.toLowerCase(); | |
| 443 | + const query = this.query.toLowerCase().trim(); | |
| 442 | 444 | return stringValues.toLowerCase().includes(query); |
| 443 | 445 | }, |
| 444 | 446 | |
| ... | ... | @@ -564,7 +566,7 @@ |
| 564 | 566 | |
| 565 | 567 | this.isFocused = true; // so we put back focus after clicking with mouse on option elements |
| 566 | 568 | } else { |
| 567 | - this.query = option.label; | |
| 569 | + this.query = String(option.label).trim(); | |
| 568 | 570 | this.values = [option]; |
| 569 | 571 | this.lastRemoteQuery = ''; |
| 570 | 572 | this.hideMenu(); |
| ... | ... | @@ -652,7 +654,7 @@ |
| 652 | 654 | // restore query value in filterable single selects |
| 653 | 655 | const [selectedOption] = this.values; |
| 654 | 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 | 658 | if (selectedLabel && this.query !== selectedLabel) { |
| 657 | 659 | this.preventRemoteCall = true; |
| 658 | 660 | this.query = selectedLabel; | ... | ... |