1
0
mirror of https://github.com/flarum/core.git synced 2025-07-16 06:16:23 +02:00

Only retain scroll position if coming from discussion (#3229)

Fixes https://discuss.flarum.org/d/29596-make-tag-hero-visible/8.

If a user has just switched from one tag to another, they want to see the entire new discussion list, and information about which tag that discussion list corresponds to. There's no good reason to not display the hero header when switching tags.
This commit is contained in:
Alexander Skvortsov
2021-12-27 18:13:29 -05:00
committed by GitHub
parent 7ababc95f3
commit afa36e71f8

View File

@ -89,9 +89,9 @@ export default class IndexPage extends Page {
// Let browser handle scrolling on page reload.
if (app.previous.type == null) return;
// When on mobile, only retain scroll if we're coming from a discussion page.
// Only retain scroll position if we're coming from a discussion page.
// Otherwise, we've just changed the filter, so we should go to the top of the page.
if (app.screen() == 'desktop' || app.screen() == 'desktop-hd' || this.lastDiscussion) {
if (this.lastDiscussion) {
$(window).scrollTop(scrollTop - oldHeroHeight + heroHeight);
} else {
$(window).scrollTop(0);