Merge pull request #1472 from alectrocute/grave-scroll-issue-bugfix

Remove scroll position set/get for `Community` and `Home`
This commit is contained in:
SleeplessOne1917 2023-06-22 16:29:59 +00:00 committed by GitHub
commit 0958dde023
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 12 deletions

View file

@ -15,7 +15,6 @@ import {
updateCommunityBlock,
updatePersonBlock,
} from "@utils/app";
import { restoreScrollPosition, saveScrollPosition } from "@utils/browser";
import {
getPageFromString,
getQueryParams,
@ -229,10 +228,6 @@ export class Community extends Component<
setupTippy();
}
componentWillUnmount() {
saveScrollPosition(this.context);
}
static async fetchInitialData({
client,
path,
@ -609,7 +604,6 @@ export class Community extends Component<
});
}
restoreScrollPosition(this.context);
setupTippy();
}

View file

@ -13,7 +13,6 @@ import {
showLocal,
updatePersonBlock,
} from "@utils/app";
import { restoreScrollPosition, saveScrollPosition } from "@utils/browser";
import {
getPageFromString,
getQueryParams,
@ -293,10 +292,6 @@ export class Home extends Component<any, HomeState> {
setupTippy();
}
componentWillUnmount() {
saveScrollPosition(this.context);
}
static async fetchInitialData({
client,
auth,
@ -800,7 +795,6 @@ export class Home extends Component<any, HomeState> {
});
}
restoreScrollPosition(this.context);
setupTippy();
}

View file

@ -1,5 +1,6 @@
export default function restoreScrollPosition(context: any) {
const path: string = context.router.route.location.pathname;
const y = Number(sessionStorage.getItem(`scrollPosition_${path}`));
window.scrollTo(0, y);
}

View file

@ -1,5 +1,6 @@
export default function saveScrollPosition(context: any) {
const path: string = context.router.route.location.pathname;
const y = window.scrollY;
sessionStorage.setItem(`scrollPosition_${path}`, y.toString());
}