Skip to content

A platform for community discussion. Free, open, simple.

UX: Keyboard shortcuts will automatically select hovered post

Bianca Nenciu758fae7f9f04
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