1
0
mirror of synced 2024-11-25 22:36:03 +03:00

Dont update the results if the term hasn't changed.

https://github.com/ivaynberg/select2/issues/2751
This commit is contained in:
Valdas Petrulis 2014-10-23 10:04:39 +03:00
parent 0cc0ac43f5
commit c1f338cfbf

View File

@ -1500,20 +1500,24 @@ the specific language governing permissions and limitations under the Apache Lic
},
/**
* @return {Boolean} Whether or not search value was changed.
* @private
*/
prefillNextSearchTerm: function () {
// initializes search's value with nextSearchTerm (if defined by user)
// ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
if(this.search.val() !== "") {
return;
return false;
}
var nextSearchTerm = this.opts.nextSearchTerm(this.data(), this.lastSearchTerm);
if(nextSearchTerm != undefined){
if(nextSearchTerm !== undefined){
this.search.val(nextSearchTerm);
this.search.select();
return true;
}
return false;
},
//abstract
@ -3013,9 +3017,10 @@ the specific language governing permissions and limitations under the Apache Lic
this.updateResults(true);
} else {
// initializes search's value with nextSearchTerm and update search result
this.prefillNextSearchTerm();
if (this.prefillNextSearchTerm()) {
this.updateResults();
}
}
this.positionDropdown();
} else {
// if nothing left to select close