]> BookStack Code Mirror - bookstack/blobdiff - resources/assets/js/components/dropdown.js
Update settings.php
[bookstack] / resources / assets / js / components / dropdown.js
index e2bb21b0cf3bfbba0cc33ea0c8094a42e78a1460..4de1e239b93b3747bd7474ad188d7684b62dfb9e 100644 (file)
@@ -112,15 +112,14 @@ class DropDown {
 
         onSelect(this.toggle, event => {
             event.stopPropagation();
-            console.log('cat', event);
             this.show(event);
             if (event instanceof KeyboardEvent) {
                 this.focusNext();
             }
         });
 
-        // Arrow navigation
-        this.container.addEventListener('keydown', event => {
+        // Keyboard navigation
+        const keyboardNavigation = event => {
             if (event.key === 'ArrowDown' || event.key === 'ArrowRight') {
                 this.focusNext();
                 event.preventDefault();
@@ -129,9 +128,14 @@ class DropDown {
                 event.preventDefault();
             } else if (event.key === 'Escape') {
                 this.hide();
+                this.toggle.focus();
                 event.stopPropagation();
             }
-        });
+        };
+        this.container.addEventListener('keydown', keyboardNavigation);
+        if (this.moveMenu) {
+            this.menu.addEventListener('keydown', keyboardNavigation);
+        }
 
         // Hide menu on enter press or escape
         this.menu.addEventListener('keydown ', event => {