Skip to content

Commit

Permalink
Merge pull request #1472 from alectrocute/grave-scroll-issue-bugfix
Browse files Browse the repository at this point in the history
Remove scroll position set/get for `Community` and `Home`
  • Loading branch information
SleeplessOne1917 authored Jun 22, 2023
2 parents 9cf09e8 + 5c302cc commit 0958dde
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 12 deletions.
6 changes: 0 additions & 6 deletions src/shared/components/community/community.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
updateCommunityBlock,
updatePersonBlock,
} from "@utils/app";
import { restoreScrollPosition, saveScrollPosition } from "@utils/browser";
import {
getPageFromString,
getQueryParams,
Expand Down Expand Up @@ -229,10 +228,6 @@ export class Community extends Component<
setupTippy();
}

componentWillUnmount() {
saveScrollPosition(this.context);
}

static async fetchInitialData({
client,
path,
Expand Down Expand Up @@ -609,7 +604,6 @@ export class Community extends Component<
});
}

restoreScrollPosition(this.context);
setupTippy();
}

Expand Down
6 changes: 0 additions & 6 deletions src/shared/components/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
showLocal,
updatePersonBlock,
} from "@utils/app";
import { restoreScrollPosition, saveScrollPosition } from "@utils/browser";
import {
getPageFromString,
getQueryParams,
Expand Down Expand Up @@ -293,10 +292,6 @@ export class Home extends Component<any, HomeState> {
setupTippy();
}

componentWillUnmount() {
saveScrollPosition(this.context);
}

static async fetchInitialData({
client,
auth,
Expand Down Expand Up @@ -800,7 +795,6 @@ export class Home extends Component<any, HomeState> {
});
}

restoreScrollPosition(this.context);
setupTippy();
}

Expand Down
1 change: 1 addition & 0 deletions src/shared/utils/browser/restore-scroll-position.ts
Original file line number Diff line number Diff line change
@@ -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);
}
1 change: 1 addition & 0 deletions src/shared/utils/browser/save-scroll-position.ts
Original file line number Diff line number Diff line change
@@ -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());
}

0 comments on commit 0958dde

Please sign in to comment.