From b053c15d6bc0fe09f5396cd39e2a00fb64b58efb Mon Sep 17 00:00:00 2001 From: Marc Neuhaus Date: Mon, 15 Feb 2016 13:10:19 +0100 Subject: [PATCH] =?UTF-8?q?[BUGFIX]=C2=A0Prevent=20form=20submission=20whi?= =?UTF-8?q?le=20autocomplete=20is=20open?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto-complete.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/auto-complete.js b/auto-complete.js index 2f5a88c..bcae80c 100644 --- a/auto-complete.js +++ b/auto-complete.js @@ -152,6 +152,9 @@ var autoComplete = (function(){ else if (key == 27) { that.value = that.last_val; that.sc.style.display = 'none'; } // enter else if (key == 13 || key == 9) { + if (that.sc.style.display !== 'none') { + e.preventDefault(); + } var sel = that.sc.querySelector('.autocomplete-suggestion.selected'); if (sel && that.sc.style.display != 'none') { o.onSelect(e, sel.getAttribute('data-val'), sel); setTimeout(function(){ that.sc.style.display = 'none'; }, 20); } }