From da1d7178a72fc3e99621053725d9866ac1d6451d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 2 May 2019 15:16:38 -0700 Subject: [PATCH] Fix scrolling issue on refetch. --- ui/src/components/communities.tsx | 1 + ui/src/components/community.tsx | 1 + ui/src/components/inbox.tsx | 1 + ui/src/components/main.tsx | 1 + ui/src/components/modlog.tsx | 1 + ui/src/components/search.tsx | 1 + ui/src/components/user.tsx | 1 + 7 files changed, 7 insertions(+) diff --git a/ui/src/components/communities.tsx b/ui/src/components/communities.tsx index 190f8e3d6..96864e9a5 100644 --- a/ui/src/components/communities.tsx +++ b/ui/src/components/communities.tsx @@ -174,6 +174,7 @@ export class Communities extends Component { this.state.communities = res.communities; this.state.communities.sort((a, b) => b.number_of_subscribers - a.number_of_subscribers); this.state.loading = false; + window.scrollTo(0,0); this.setState(this.state); } else if (op == UserOperation.FollowCommunity) { let res: CommunityResponse = msg; diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index 93cdbd92f..28841a2e5 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -215,6 +215,7 @@ export class Community extends Component { let res: GetPostsResponse = msg; this.state.posts = res.posts; this.state.loading = false; + window.scrollTo(0,0); this.setState(this.state); } else if (op == UserOperation.CreatePostLike) { let res: CreatePostLikeResponse = msg; diff --git a/ui/src/components/inbox.tsx b/ui/src/components/inbox.tsx index 659a4a20d..69ddc44b4 100644 --- a/ui/src/components/inbox.tsx +++ b/ui/src/components/inbox.tsx @@ -170,6 +170,7 @@ export class Inbox extends Component { let res: GetRepliesResponse = msg; this.state.replies = res.replies; this.sendRepliesCount(); + window.scrollTo(0,0); this.setState(this.state); } else if (op == UserOperation.EditComment) { let res: CommentResponse = msg; diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index cd679ecb9..1ec016ea6 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -383,6 +383,7 @@ export class Main extends Component { let res: GetPostsResponse = msg; this.state.posts = res.posts; this.state.loading = false; + window.scrollTo(0,0); this.setState(this.state); } else if (op == UserOperation.CreatePostLike) { let res: CreatePostLikeResponse = msg; diff --git a/ui/src/components/modlog.tsx b/ui/src/components/modlog.tsx index 853bdd204..894887ae1 100644 --- a/ui/src/components/modlog.tsx +++ b/ui/src/components/modlog.tsx @@ -228,6 +228,7 @@ export class Modlog extends Component { } else if (op == UserOperation.GetModlog) { let res: GetModlogResponse = msg; this.state.loading = false; + window.scrollTo(0,0); this.setCombined(res); } } diff --git a/ui/src/components/search.tsx b/ui/src/components/search.tsx index f066f6ed6..7c72939a7 100644 --- a/ui/src/components/search.tsx +++ b/ui/src/components/search.tsx @@ -251,6 +251,7 @@ export class Search extends Component { this.state.searchResponse = res; this.state.loading = false; document.title = `Search - ${this.state.q} - Lemmy`; + window.scrollTo(0,0); this.setState(this.state); } diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index 92ad53359..4cd88abc8 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -342,6 +342,7 @@ export class User extends Component { this.state.posts = res.posts; this.state.loading = false; document.title = `/u/${this.state.user.name} - Lemmy`; + window.scrollTo(0,0); this.setState(this.state); } else if (op == UserOperation.EditComment) { let res: CommentResponse = msg;