Fixed suggestion list handling
authorAlexander Ebert <ebert@woltlab.com>
Tue, 25 Apr 2017 15:37:10 +0000 (17:37 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 25 Apr 2017 15:37:10 +0000 (17:37 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Suggestion.js

index 2db4a579319728628b57c037db7a24177f2b609e..30ad9035923cb8337d501c903989d1f779f32b96 100644 (file)
@@ -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);
                }
index d655c127065c2e375404af0b6b336fad8a04b5c8..510a6b42696b29d8bac8002a5da638246a2cd1fa 100644 (file)
@@ -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;
                        }