From: Dessalines Date: Thu, 18 Nov 2021 15:37:24 +0000 (-0500) Subject: Fix comment scroll bug. Fixes #492 X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%22https:/nerdica.net/%7B?a=commitdiff_plain;h=aff768edaa89262abcd6bfea932be0c17bbd278d;p=lemmy-ui.git Fix comment scroll bug. Fixes #492 --- diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index 499330c..f68d77a 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -218,11 +218,15 @@ export class Post extends Component { } scrollCommentIntoView() { - var elmnt = document.getElementById(`comment-${this.state.commentId}`); - elmnt.scrollIntoView(); - elmnt.classList.add("mark"); - this.state.scrolled = true; - this.markScrolledAsRead(this.state.commentId); + let commentElement = document.getElementById( + `comment-${this.state.commentId}` + ); + if (commentElement) { + commentElement.scrollIntoView(); + commentElement.classList.add("mark"); + this.state.scrolled = true; + this.markScrolledAsRead(this.state.commentId); + } } get checkScrollIntoCommentsParam() {