From a1125ddbf0ef5ffddaab0df49c3a09b2abe88c58 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 14 Feb 2022 14:10:11 -0500 Subject: [PATCH] Fix comment jumping. Fixes #529 (#576) --- src/shared/components/post/post.tsx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 4ae1cc5..9b59859 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -195,16 +195,7 @@ export class Post extends Component { document.addEventListener("scroll", this.commentScrollDebounced); } - componentDidUpdate(_lastProps: any, lastState: PostState) { - if ( - this.state.commentId && - !this.state.scrolled && - lastState.postRes && - lastState.postRes.comments.length > 0 - ) { - this.scrollCommentIntoView(); - } - + componentDidUpdate(_lastProps: any) { // Necessary if you are on a post and you click another post (same route) if (_lastProps.location.pathname !== _lastProps.history.location.pathname) { // TODO Couldnt get a refresh working. This does for now. @@ -548,6 +539,10 @@ export class Post extends Component { if (this.checkScrollIntoCommentsParam) { this.scrollIntoCommentSection(); } + + if (this.state.commentId && !this.state.scrolled) { + this.scrollCommentIntoView(); + } } else if (op == UserOperation.CreateComment) { let data = wsJsonToRes(msg).data; -- 2.44.1