Skip to content

Commit b13c9b4

Browse files
author
Kevin Brown
committed
Small formatMatches change for single results
This changes `formatMatches` to notify the user that they can select the single result. This is a more clear result compared to the previous one. This closes the following issue: https://github.com/ivaynberg/select2/issues/2329
1 parent 172f973 commit b13c9b4

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

select2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ the specific language governing permissions and limitations under the Apache Lic
11101110
this.attachEvent("onpropertychange", self._sync);
11111111
});
11121112
}
1113-
1113+
11141114
// safari, chrome, firefox, IE11
11151115
observer = window.MutationObserver || window.WebKitMutationObserver|| window.MozMutationObserver;
11161116
if (observer !== undefined) {
@@ -1349,7 +1349,7 @@ the specific language governing permissions and limitations under the Apache Lic
13491349
lastMousePosition.x = e.pageX;
13501350
lastMousePosition.y = e.pageY;
13511351
});
1352-
1352+
13531353
return true;
13541354
},
13551355

@@ -3397,7 +3397,7 @@ the specific language governing permissions and limitations under the Apache Lic
33973397
},
33983398
formatResultCssClass: function(data) {return data.css;},
33993399
formatSelectionCssClass: function(data, container) {return undefined;},
3400-
formatMatches: function (matches) { return matches + " results are available, use up and down arrow keys to navigate."; },
3400+
formatMatches: function (matches) { if (matches === 1) { return "One result is available, press enter to select it."; } return matches + " results are available, use up and down arrow keys to navigate."; },
34013401
formatNoMatches: function () { return "No matches found"; },
34023402
formatInputTooShort: function (input, min) { var n = min - input.length; return "Please enter " + n + " or more character" + (n == 1? "" : "s"); },
34033403
formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1? "" : "s"); },

select2_locale_en.js.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/**
22
* Select2 <Language> translation.
3-
*
3+
*
44
* Author: Your Name <your@email>
55
*/
66
(function ($) {
77
"use strict";
88

99
$.extend($.fn.select2.defaults, {
10-
formatMatches: function (matches) { return matches + " results are available, use up and down arrow keys to navigate."; },
10+
formatMatches: function (matches) { if (matches === 1) { return "One result is available, press enter to select it."; } return matches + " results are available, use up and down arrow keys to navigate."; },
1111
formatNoMatches: function () { return "No matches found"; },
1212
formatInputTooShort: function (input, min) { var n = min - input.length; return "Please enter " + n + " or more character" + (n == 1 ? "" : "s"); },
1313
formatInputTooLong: function (input, max) { var n = input.length - max; return "Please delete " + n + " character" + (n == 1 ? "" : "s"); },

0 commit comments

Comments
 (0)