Commit c3304bce349cb652f68b56a68360bbe3fd902f2b

Authored by Sergio Crisostomo
1 parent 31788df3

correct unchangedQuery and queryStringMatchesSelectedOption logic and

src/components/select/select-head.vue
... ... @@ -182,6 +182,7 @@
182 182 // #982
183 183 if (typeof value === 'undefined' || value === '' || value === null) this.query = '';
184 184 else this.query = value.label;
  185 + this.$nextTick(() => this.preventRemoteCall = false); // this should be after the query change setter above
185 186 },
186 187 query (val) {
187 188 if (this.preventRemoteCall) {
... ...
src/components/select/select.vue
... ... @@ -266,7 +266,7 @@
266 266 },
267 267 queryStringMatchesSelectedOption(){
268 268 const selectedOptions = this.values[0];
269   - return selectedOptions && !this.multiple && this.unchangedQuery && this.query === selectedOptions.value;
  269 + return selectedOptions && !this.multiple && this.unchangedQuery && this.query === selectedOptions.label;
270 270 },
271 271 localeNotFoundText () {
272 272 if (typeof this.notFoundText === 'undefined') {
... ... @@ -391,6 +391,7 @@
391 391 },
392 392 clearSingleSelect(){ // PUBLIC API
393 393 this.$emit('on-clear');
  394 + this.hideMenu();
394 395 if (this.clearable) this.values = [];
395 396 },
396 397 getOptionData(value){
... ... @@ -437,7 +438,8 @@
437 438 const label = propsData.label || '';
438 439 const textContent = elm && elm.textContent || '';
439 440 const stringValues = JSON.stringify([value, label, textContent]);
440   - return stringValues.toLowerCase().includes(this.query.toLowerCase());
  441 + const query = this.query.toLowerCase();
  442 + return stringValues.toLowerCase().includes(query);
441 443 },
442 444  
443 445 toggleMenu (e, force) {
... ... @@ -563,7 +565,7 @@
563 565  
564 566 this.isFocused = true; // so we put back focus after clicking with mouse on option elements
565 567 } else {
566   - this.query = option.value;
  568 + this.query = option.label;
567 569 this.values = [option];
568 570 this.lastRemoteQuery = '';
569 571 this.hideMenu();
... ... @@ -576,9 +578,9 @@
576 578 this.broadcast('Drop', 'on-update-popper');
577 579 },
578 580 onQueryChange(query) {
579   - this.unchangedQuery = false;
  581 + if (query.length > 0 && query !== this.query) this.visible = true;
580 582 this.query = query;
581   - if (this.query.length > 0) this.visible = true;
  583 + this.unchangedQuery = this.visible;
582 584 },
583 585 toggleHeaderFocus({type}){
584 586 if (this.disabled) {
... ...