From ba0e4995993961d0165388c66a075782d03b022a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 25 Apr 2017 17:37:10 +0200 Subject: [PATCH] Fixed suggestion list handling --- .../install/files/js/WoltLabSuite/Core/Ui/ItemList.js | 7 +++++-- .../files/js/WoltLabSuite/Core/Ui/Suggestion.js | 10 +++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) 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; } -- 2.20.1