From 70012f20278430362649a26a28d3cb4b39449b64 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Wed, 25 Mar 2020 06:45:35 +0200 Subject: [PATCH] FEATURE: Navigate through search results using J/K (#9264) --- app/assets/javascripts/discourse/lib/keyboard-shortcuts.js | 6 +++++- app/assets/stylesheets/common/base/search.scss | 2 ++ .../stylesheets/common/components/keyboard_shortcuts.scss | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js index 5da8be5bc97..064c2eeb587 100644 --- a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js +++ b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js @@ -53,7 +53,8 @@ export let bindings = { ".topic-list tr.selected a.title", ".latest-topic-list .latest-topic-list-item.selected div.main-link a.title", ".top-topic-list .latest-topic-list-item.selected div.main-link a.title", - ".latest .featured-topic.selected a.title" + ".latest .featured-topic.selected a.title", + ".search-results .search-link" ].join(", "), anonymous: true }, // open selected topic on latest or categories page @@ -589,6 +590,7 @@ export default { const $topicList = $(".topic-list"); const $postsWrapper = $(".posts-wrapper"); const $categoriesTopicsList = this.categoriesTopicsList(); + const $searchResults = $(".search-results"); if ($postsWrapper.length > 0) { return $(".posts-wrapper .topic-post, .topic-list tbody tr"); @@ -596,6 +598,8 @@ export default { return $topicList.find(".topic-list-item"); } else if ($categoriesTopicsList.length > 0) { return $categoriesTopicsList; + } else if ($searchResults.length > 0) { + return $searchResults.find(".fps-result"); } }, diff --git a/app/assets/stylesheets/common/base/search.scss b/app/assets/stylesheets/common/base/search.scss index 9561a6b47d6..e62f24f2921 100644 --- a/app/assets/stylesheets/common/base/search.scss +++ b/app/assets/stylesheets/common/base/search.scss @@ -192,6 +192,8 @@ .fps-result { display: flex; + padding: 0 0.5em; + .author { display: inline-block; vertical-align: top; diff --git a/app/assets/stylesheets/common/components/keyboard_shortcuts.scss b/app/assets/stylesheets/common/components/keyboard_shortcuts.scss index c40eaefee96..e74397664b7 100644 --- a/app/assets/stylesheets/common/components/keyboard_shortcuts.scss +++ b/app/assets/stylesheets/common/components/keyboard_shortcuts.scss @@ -5,7 +5,8 @@ .topic-list tr.selected td:first-child, .topic-list-item.selected td:first-child, -.latest-topic-list-item.selected { +.latest-topic-list-item.selected, +.search-results .fps-result.selected { box-shadow: inset 3px 0 0 $danger; // needs to be inset for Edge }