From: Dessalines Date: Mon, 14 Feb 2022 19:10:11 +0000 (-0500) Subject: Fix comment jumping. Fixes #529 (#576) X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/hacktivis.me/README.es.md?a=commitdiff_plain;h=a1125ddbf0ef5ffddaab0df49c3a09b2abe88c58;p=lemmy-ui.git Fix comment jumping. Fixes #529 (#576) --- 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;