A platform for community discussion. Free, open, simple.
FIX: Regression in topic list kbd navigation (#15513)
Penar Musarajc908fa2f5b00
diff --git a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.jsindex 16f7f9a5b7b..df5d4db4dff 100644--- a/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js+++ b/app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js@@ -694,7 +694,8 @@ export default {selectedArticle: article,});- const articleTop = domUtils.offset(article).top;+ const articleTop = domUtils.offset(article).top,+ articleTopPosition = articleTop - headerOffset();if (!fast && direction < 0 && article.offsetHeight > window.innerHeight) {// Scrolling to the last "page" of the previous post if post has multiple// "pages" (if its height does not fit in the screen).@@ -703,16 +704,22 @@ export default {);} else if (article.classList.contains("topic-post")) {return this._scrollTo(- article.querySelector("#post_1") ? 0 : articleTop - headerOffset(),+ article.querySelector("#post_1") ? 0 : articleTopPosition,{ focusTabLoc: true });}- // Otherwise scroll through the suggested topic list.- article.scrollIntoView({- behavior: "smooth",- block: "center",- });+ // Otherwise scroll through the topic list.+ if (+ articleTopPosition > window.pageYOffset &&+ articleTop + article.offsetHeight <+ window.pageYOffset + window.innerHeight+ ) {+ return;+ }++ const scrollRatio = direction > 0 ? 0.2 : 0.7;+ this._scrollTo(articleTopPosition - window.innerHeight * scrollRatio);},_scrollTo(scrollTop, opts = {}) {