mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Call preventDefault() when a keyboard shortcut is executed
This commit is contained in:
parent
8c65c78904
commit
9440bf47a5
4 changed files with 18 additions and 14 deletions
2
ui/static/js/bootstrap.js
vendored
2
ui/static/js/bootstrap.js
vendored
|
@ -29,7 +29,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
keyboardHandler.on("f", () => navHandler.toggleBookmark());
|
||||
keyboardHandler.on("?", () => navHandler.showKeyboardShortcuts());
|
||||
keyboardHandler.on("#", () => navHandler.unsubscribeFromFeed());
|
||||
keyboardHandler.on("/", (e) => navHandler.setFocusToSearchInput(e));
|
||||
keyboardHandler.on("/", () => navHandler.setFocusToSearchInput());
|
||||
keyboardHandler.on("Escape", () => ModalHandler.close());
|
||||
keyboardHandler.listen();
|
||||
|
||||
|
|
|
@ -21,14 +21,12 @@ class KeyboardHandler {
|
|||
let keys = combination.split(" ");
|
||||
|
||||
if (keys.every((value, index) => value === this.queue[index])) {
|
||||
this.queue = [];
|
||||
this.shortcuts[combination](event);
|
||||
this.execute(combination, event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (keys.length === 1 && key === keys[0]) {
|
||||
this.queue = [];
|
||||
this.shortcuts[combination](event);
|
||||
this.execute(combination, event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +37,14 @@ 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";
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
class NavHandler {
|
||||
setFocusToSearchInput(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
setFocusToSearchInput() {
|
||||
let toggleSwitchElement = document.querySelector(".search-toggle-switch");
|
||||
if (toggleSwitchElement) {
|
||||
toggleSwitchElement.style.display = "none";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue