From 7c6f752392aad6ff3949060edbb191b2b7bd2362 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 30 Jul 2013 15:23:17 +0200 Subject: [PATCH] Improved WCF.Search.Base/WCF.EditableItemList --- wcfsetup/install/files/js/WCF.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index ef2a14de27..6359131686 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -5315,11 +5315,15 @@ WCF.Search.Base = Class.extend({ * @param object event */ _keyDown: function(event) { - if (event.which === 13) { - if (this._searchInput.parents('.dropdown').data('disableAutoFocus') && this._itemIndex === -1) { - // allow submitting + if (event.which === $.ui.keyCode.ENTER) { + var $dropdown = this._searchInput.parents('.dropdown'); + + if ($dropdown.data('disableAutoFocus')) { + if (this._itemIndex !== -1) { + event.preventDefault(); + } } - else { + else if ($dropdown.data('preventSubmit') || this._itemIndex !== -1) { event.preventDefault(); } } @@ -7639,6 +7643,9 @@ WCF.EditableItemList = Class.extend({ setTimeout(function() { self._onPaste(); }, 100); }); } + + // block form submit through [ENTER] + this._searchInput.parents('.dropdown').data('preventSubmit', true); }, /** @@ -7648,7 +7655,13 @@ WCF.EditableItemList = Class.extend({ */ _keyDown: function(event) { // 188 = [,] - if (event === null || event.which === 188) { + if (event === null || event.which === 188 || event.which === $.ui.keyCode.ENTER) { + if (event.which === $.ui.keyCode.ENTER && this._search) { + if (this._search._itemIndex !== -1) { + return false; + } + } + var $value = $.trim(this._searchInput.val()); // read everything left from caret position -- 2.20.1