From 758fae7f9f049e2bc50f49146db8b22b18ff3d0d Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Wed, 22 Aug 2018 07:47:17 +0200 Subject: [PATCH] UX: Keyboard shortcuts will automatically select hovered post --- .../javascripts/discourse/lib/keyboard-shortcuts.js.es6 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 index 5e3907da2c9..37d6db132f0 100644 --- a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 +++ b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 @@ -297,10 +297,14 @@ export default { sendToSelectedPost(action) { const container = this.container; // TODO: We should keep track of the post without a CSS class - const selectedPostId = parseInt( + let selectedPostId = parseInt( $(".topic-post.selected article.boxed").data("post-id"), 10 ); + if (!selectedPostId) { + // If no post was selected, automatically select the hovered post. + selectedPostId = parseInt($("article.boxed:hover").data("post-id"), 10); + } if (selectedPostId) { const topicController = container.lookup("controller:topic"); const post = topicController