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