Skip to content

Commit e4f138f

Browse files
Merge pull request #55 from scarfacedeb/close_when_empty
Update AlphaNum keyboard mapping to close autocomplete when currentValue is empty or too small
2 parents 18b3fee + c52f05b commit e4f138f

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

dist/autocomplete.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var EventType;
2525
* @class
2626
* @author Baptiste Donaux <baptiste.donaux@gmail.com> @baptistedonaux
2727
*/
28-
var AutoComplete = (function () {
28+
var AutoComplete = /** @class */ (function () {
2929
// Constructor
3030
function AutoComplete(params, selector) {
3131
if (params === void 0) { params = {}; }
@@ -302,6 +302,9 @@ var AutoComplete = (function () {
302302
this._Open();
303303
}.bind(this));
304304
}
305+
else {
306+
this._Close();
307+
}
305308
},
306309
Operator: ConditionOperator.AND,
307310
Event: EventType.KEYUP
@@ -385,7 +388,7 @@ var AutoComplete = (function () {
385388
_Blur: function (now) {
386389
if (now === void 0) { now = false; }
387390
if (now) {
388-
this.DOMResults.setAttribute("class", "autocomplete");
391+
this._Close();
389392
}
390393
else {
391394
var params = this;
@@ -422,6 +425,9 @@ var AutoComplete = (function () {
422425
}
423426
});
424427
},
428+
_Close: function () {
429+
this.DOMResults.setAttribute("class", "autocomplete");
430+
},
425431
/**
426432
* Position the results HTML element
427433
*/

dist/autocomplete.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/autocomplete.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ interface Params {
3939
_Limit: any;
4040
_MinChars: any;
4141
_Open: any;
42+
_Close: any;
4243
_Position: any;
4344
_Post: any;
4445
_Pre: any;
@@ -225,6 +226,8 @@ class AutoComplete {
225226
}.bind(this),
226227
this._Error
227228
);
229+
} else {
230+
this._Close();
228231
}
229232
},
230233
Operator: ConditionOperator.AND,
@@ -327,7 +330,7 @@ class AutoComplete {
327330
*/
328331
_Blur: function(now: boolean = false): void {
329332
if (now) {
330-
this.DOMResults.setAttribute("class", "autocomplete");
333+
this._Close();
331334
} else {
332335
var params = this;
333336
setTimeout(function() {
@@ -368,6 +371,10 @@ class AutoComplete {
368371
});
369372
},
370373

374+
_Close: function(): void {
375+
this.DOMResults.setAttribute("class", "autocomplete");
376+
},
377+
371378
/**
372379
* Position the results HTML element
373380
*/

0 commit comments

Comments
 (0)