FIX: Regression in topic list kbd navigation (#15513)

This commit is contained in:
Penar Musaraj 2022-01-09 17:22:41 -05:00 committed by GitHub
parent 71cf6839ab
commit c908fa2f5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 7 deletions

View File

@ -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 = {}) {