Skip to content

Commit c2bb2a5

Browse files
Merge pull request #47 from dalf/enter_fix
[FIX] the enclosing form is submited when the user presses enter while autocompletejs shows choices
2 parents bb85358 + 671c9c2 commit c2bb2a5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

dist/autocomplete.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ var AutoComplete = (function () {
194194
}],
195195
Callback: function (event) {
196196
if (this.DOMResults.getAttribute("class").indexOf("open") != -1) {
197-
event.preventDefault();
198197
var liActive = this.DOMResults.querySelector("li.active");
199198
if (liActive !== null) {
199+
event.preventDefault();
200+
200201
this._Select(liActive);
201202
this.DOMResults.setAttribute("class", "autocomplete");
202203
}

src/autocomplete.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,10 @@ class AutoComplete {
133133
}],
134134
Callback: function(event) {
135135
if (this.DOMResults.getAttribute("class").indexOf("open") != -1) {
136-
event.preventDefault();
137-
138136
var liActive = this.DOMResults.querySelector("li.active");
139137

140138
if (liActive !== null) {
139+
event.preventDefault();
141140
this._Select(liActive);
142141
this.DOMResults.setAttribute("class", "autocomplete");
143142
}
@@ -211,7 +210,7 @@ class AutoComplete {
211210
Callback: function() {
212211
var oldValue = this.Input.getAttribute("data-autocomplete-old-value"),
213212
currentValue = this._Pre();
214-
213+
215214
if (currentValue !== "" && currentValue.length >= this._MinChars()) {
216215
if (!oldValue || currentValue != oldValue) {
217216
this.DOMResults.setAttribute("class", "autocomplete open");
@@ -275,7 +274,7 @@ class AutoComplete {
275274
return this.MinChars;
276275
}
277276

278-
return parseInt(minchars, 10);
277+
return parseInt(minchars, 10);
279278
},
280279

281280
/**

0 commit comments

Comments
 (0)