From: Alexander Ebert Date: Tue, 30 Jul 2013 13:23:17 +0000 (+0200) Subject: Improved WCF.Search.Base/WCF.EditableItemList X-Git-Tag: 2.0.0_Beta_6~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7c6f752392aad6ff3949060edbb191b2b7bd2362;p=GitHub%2FWoltLab%2FWCF.git Improved WCF.Search.Base/WCF.EditableItemList --- 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