Skip to content

Commit d7feb8a

Browse files
cancel form send for press enter key
1 parent ae4c29c commit d7feb8a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/autocomplete.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ class AutoComplete {
111111
this._Select(liActive);
112112
this.DOMResults.setAttribute("class", "autocomplete");
113113
}
114+
115+
// Cancel form send only if results element is open
116+
event.preventDefault();
114117
}
115118
},
116119
Operator: ConditionOperator.AND
@@ -426,7 +429,7 @@ class AutoComplete {
426429

427430
params.Input.addEventListener("focus", params._Focus.bind(params));
428431

429-
params.Input.addEventListener("keyup", AutoComplete.prototype.event.bind(null, params));
432+
params.Input.addEventListener("keydown", AutoComplete.prototype.event.bind(null, params));
430433

431434
params.Input.addEventListener("blur", params._Blur.bind(params));
432435
params.Input.addEventListener("position", params._Position.bind(params));

0 commit comments

Comments
 (0)