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 e926758060
commit 206aa227f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);