From: Alexander Ebert Date: Tue, 25 Apr 2017 15:37:10 +0000 (+0200) Subject: Fixed suggestion list handling X-Git-Tag: 3.0.5~32 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ba0e4995993961d0165388c66a075782d03b022a;p=GitHub%2FWoltLab%2FWCF.git Fixed suggestion list handling --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js index 2db4a57931..30ad903592 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js @@ -468,7 +468,8 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'EventKey', 'WoltLabSu * @param {object} event event object */ _blur: function(event) { - if (_data.get(event.currentTarget.id).options.restricted) { + var data = _data.get(event.currentTarget.id); + if (data.options.restricted) { // restricted item lists only allow results from the dropdown to be picked return; } @@ -477,7 +478,9 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'EventKey', 'WoltLabSu window.setTimeout(function() { var value = currentTarget.value.trim(); if (value.length) { - this._addItem(currentTarget.id, { objectId: 0, value: value }); + if (!data.suggestion || !data.suggestion.isActive()) { + this._addItem(currentTarget.id, { objectId: 0, value: value }); + } } }.bind(this), 100); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Suggestion.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Suggestion.js index d655c12706..510a6b4269 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Suggestion.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Suggestion.js @@ -81,13 +81,21 @@ define(['Ajax', 'Core', 'Ui/SimpleDropdown'], function(Ajax, Core, UiSimpleDropd } }, + /** + * Returns true if the suggestions are active. + * @return {boolean} + */ + isActive: function() { + return (this._dropdownMenu !== null && UiSimpleDropdown.isOpen(this._element.id)); + }, + /** * Handles the keyboard navigation for interaction with the suggestion list. * * @param {object} event event object */ _keyDown: function(event) { - if (this._dropdownMenu === null || !UiSimpleDropdown.isOpen(this._element.id)) { + if (!this.isActive()) { return true; }