From 97cdc67c1a6ba3b5bef22cc99c240eb63bae6652 Mon Sep 17 00:00:00 2001 From: Marcus Jaschen Date: Thu, 15 Dec 2016 09:38:15 +0100 Subject: [PATCH] fix: listen to `keyup` instead of `keypress` for search field activation The `/` character is entered into the search field after activating it via the `keypress` event. That's unexpected behaviour. This commit fixes that by attaching the keyboard event handler to the `keyup` event. --- assets/js/all.js | 20 ++++++++++++++++---- assets/js/event.js | 20 ++++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/assets/js/all.js b/assets/js/all.js index ff45191..286627a 100644 --- a/assets/js/all.js +++ b/assets/js/all.js @@ -713,10 +713,6 @@ Miniflux.Event = (function() { case 63: Miniflux.Nav.ShowHelp(); break; - case '/': - case 47: - Miniflux.Nav.ShowSearch(); - break; case 'Q': case 81: // Q case 'q': @@ -752,6 +748,22 @@ Miniflux.Event = (function() { break; } }; + + document.onkeyup = function(e) { + + if (isEventIgnored(e)) { + return; + } + + Miniflux.Event.lastEventType = "keyboard"; + + switch (e.key || e.which) { + case '/': + case 47: + Miniflux.Nav.ShowSearch(); + break; + } + }; }, ListenVisibilityEvents: function() { document.addEventListener('visibilitychange', function() { diff --git a/assets/js/event.js b/assets/js/event.js index 4b840db..deb4dca 100644 --- a/assets/js/event.js +++ b/assets/js/event.js @@ -196,10 +196,6 @@ Miniflux.Event = (function() { case 63: Miniflux.Nav.ShowHelp(); break; - case '/': - case 47: - Miniflux.Nav.ShowSearch(); - break; case 'Q': case 81: // Q case 'q': @@ -235,6 +231,22 @@ Miniflux.Event = (function() { break; } }; + + document.onkeyup = function(e) { + + if (isEventIgnored(e)) { + return; + } + + Miniflux.Event.lastEventType = "keyboard"; + + switch (e.key || e.which) { + case '/': + case 47: + Miniflux.Nav.ShowSearch(); + break; + } + }; }, ListenVisibilityEvents: function() { document.addEventListener('visibilitychange', function() {