Browse Source

Revert "Call preventDefault() when a keyboard shortcut is executed"

This reverts commit 9440bf47a521a61c91073425bd613710cf7dd1cb.
Frédéric Guillot 7 years ago
parent
commit
f06a19814b
4 changed files with 12 additions and 16 deletions
  1. 3 4
      ui/static/js.go
  2. 1 1
      ui/static/js/bootstrap.js
  3. 4 10
      ui/static/js/keyboard_handler.js
  4. 4 1
      ui/static/js/nav_handler.js

File diff suppressed because it is too large
+ 3 - 4
ui/static/js.go


+ 1 - 1
ui/static/js/bootstrap.js

@@ -29,7 +29,7 @@ document.addEventListener("DOMContentLoaded", function() {
     keyboardHandler.on("f", () => navHandler.toggleBookmark());
     keyboardHandler.on("?", () => navHandler.showKeyboardShortcuts());
     keyboardHandler.on("#", () => navHandler.unsubscribeFromFeed());
-    keyboardHandler.on("/", () => navHandler.setFocusToSearchInput());
+    keyboardHandler.on("/", (e) => navHandler.setFocusToSearchInput(e));
     keyboardHandler.on("Escape", () => ModalHandler.close());
     keyboardHandler.listen();
 

+ 4 - 10
ui/static/js/keyboard_handler.js

@@ -21,12 +21,14 @@ class KeyboardHandler {
                 let keys = combination.split(" ");
 
                 if (keys.every((value, index) => value === this.queue[index])) {
-                    this.execute(combination, event);
+                    this.queue = [];
+                    this.shortcuts[combination](event);
                     return;
                 }
 
                 if (keys.length === 1 && key === keys[0]) {
-                    this.execute(combination, event);
+                    this.queue = [];
+                    this.shortcuts[combination](event);
                     return;
                 }
             }
@@ -37,14 +39,6 @@ class KeyboardHandler {
         };
     }
 
-    execute(combination, event) {
-        event.preventDefault();
-        event.stopPropagation();
-
-        this.queue = [];
-        this.shortcuts[combination](event);
-    }
-
     isEventIgnored(event) {
         return event.target.tagName === "INPUT" || event.target.tagName === "TEXTAREA";
     }

+ 4 - 1
ui/static/js/nav_handler.js

@@ -1,5 +1,8 @@
 class NavHandler {
-    setFocusToSearchInput() {
+    setFocusToSearchInput(event) {
+        event.preventDefault();
+        event.stopPropagation();
+
         let toggleSwitchElement = document.querySelector(".search-toggle-switch");
         if (toggleSwitchElement) {
             toggleSwitchElement.style.display = "none";

Some files were not shown because too many files changed in this diff