Skip to content

Commit 314991e

Browse files
committed
[FIX] the enclosing form is submited when the user presses enter while autocompletejs shows choices
1 parent 9dbb139 commit 314991e

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

dist/autocomplete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ AutoComplete.defaults = {
207207
}],
208208
Callback: function (event) {
209209
if (this.DOMResults.getAttribute("class").indexOf("open") != -1) {
210-
event.preventDefault();
211210
var liActive = this.DOMResults.querySelector("li.active");
212211
if (liActive !== null) {
212+
event.preventDefault();
213213
this._Select(liActive);
214214
this.DOMResults.setAttribute("class", "autocomplete");
215215
}

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: 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)