Skip to content

Commit c1f338c

Browse files
committed
Dont update the results if the term hasn't changed.
https://github.com/ivaynberg/select2/issues/2751
1 parent 0cc0ac4 commit c1f338c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

select2.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,20 +1500,24 @@ the specific language governing permissions and limitations under the Apache Lic
15001500
},
15011501

15021502
/**
1503+
* @return {Boolean} Whether or not search value was changed.
15031504
* @private
15041505
*/
15051506
prefillNextSearchTerm: function () {
15061507
// initializes search's value with nextSearchTerm (if defined by user)
15071508
// ignore nextSearchTerm if the dropdown is opened by the user pressing a letter
15081509
if(this.search.val() !== "") {
1509-
return;
1510+
return false;
15101511
}
15111512

15121513
var nextSearchTerm = this.opts.nextSearchTerm(this.data(), this.lastSearchTerm);
1513-
if(nextSearchTerm != undefined){
1514+
if(nextSearchTerm !== undefined){
15141515
this.search.val(nextSearchTerm);
15151516
this.search.select();
1517+
return true;
15161518
}
1519+
1520+
return false;
15171521
},
15181522

15191523
//abstract
@@ -3013,8 +3017,9 @@ the specific language governing permissions and limitations under the Apache Lic
30133017
this.updateResults(true);
30143018
} else {
30153019
// initializes search's value with nextSearchTerm and update search result
3016-
this.prefillNextSearchTerm();
3017-
this.updateResults();
3020+
if (this.prefillNextSearchTerm()) {
3021+
this.updateResults();
3022+
}
30183023
}
30193024
this.positionDropdown();
30203025
} else {

0 commit comments

Comments
 (0)