Reset list state if suggestion was closed
authorAlexander Ebert <ebert@woltlab.com>
Tue, 23 Jan 2018 15:58:48 +0000 (16:58 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 23 Jan 2018 15:58:48 +0000 (16:58 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Input.js

index 5e3fbb0f25261feb5da07dd65becc58935ed3554..91a0f4d5a6ca826277fc28b1a9cb9cfdb913dba1 100644 (file)
@@ -110,24 +110,25 @@ define(['Ajax', 'Core', 'EventKey', 'Dom/Util', 'Ui/SimpleDropdown'], function(A
                _keyup: function(event) {
                        // handle dropdown keyboard navigation
                        if (this._activeItem !== null) {
-                               if (!UiSimpleDropdown.isOpen(this._dropdownContainerId)) {
-                                       return;
-                               }
-                               
-                               if (EventKey.ArrowUp(event)) {
-                                       event.preventDefault();
-                                       
-                                       return this._keyboardPreviousItem();
-                               }
-                               else if (EventKey.ArrowDown(event)) {
-                                       event.preventDefault();
-                                       
-                                       return this._keyboardNextItem();
+                               if (UiSimpleDropdown.isOpen(this._dropdownContainerId)) {
+                                       if (EventKey.ArrowUp(event)) {
+                                               event.preventDefault();
+                                               
+                                               return this._keyboardPreviousItem();
+                                       }
+                                       else if (EventKey.ArrowDown(event)) {
+                                               event.preventDefault();
+                                               
+                                               return this._keyboardNextItem();
+                                       }
+                                       else if (EventKey.Enter(event)) {
+                                               event.preventDefault();
+                                               
+                                               return this._keyboardSelectItem();
+                                       }
                                }
-                               else if (EventKey.Enter(event)) {
-                                       event.preventDefault();
-                                       
-                                       return this._keyboardSelectItem();
+                               else {
+                                       this._activeItem = null;
                                }
                        }