From 9372404a31fd818bcd3434cf5664a6c0a22a367a Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 19 Feb 2024 09:16:46 +1100 Subject: [PATCH] FIX: full post jump not working (#25734) Full post jump "SHIFT+K/J" not working if related topics are displayed Amended logic so we unconditionally use full post jump on topic pages by checking for .post-stream --- .../discourse/app/lib/keyboard-shortcuts.js | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js index 22dc109d1f9..cf421dce690 100644 --- a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js +++ b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js @@ -832,17 +832,18 @@ export default { }, _changeSection(direction) { - const sections = Array.from(document.querySelectorAll(".nav.nav-pills li")); - const active = document.querySelector(".nav.nav-pills li.active"); - const index = sections.indexOf(active) + direction; - - if (index >= 0 && index < sections.length) { - sections[index].querySelector("a")?.click(); - } - - if (sections.length === 0) { - // use for in post navigation + if (document.querySelector(".post-stream")) { this._moveSelection({ direction, scrollWithinPosts: false }); + } else { + const sections = Array.from( + document.querySelectorAll(".nav.nav-pills li") + ); + const active = document.querySelector(".nav.nav-pills li.active"); + const index = sections.indexOf(active) + direction; + + if (index >= 0 && index < sections.length) { + sections[index].querySelector("a, button")?.click(); + } } },