From 8865275585f074c36db0eca69571d78876a71e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Nunes?= Date: Mon, 9 Dec 2024 21:26:19 +0000 Subject: [PATCH] feat: ensure highlighted comment is visible --- src/pages/common/CommentsV2/CommentSectionV2.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pages/common/CommentsV2/CommentSectionV2.tsx b/src/pages/common/CommentsV2/CommentSectionV2.tsx index af81c9401b..f3eb2b8483 100644 --- a/src/pages/common/CommentsV2/CommentSectionV2.tsx +++ b/src/pages/common/CommentsV2/CommentSectionV2.tsx @@ -60,6 +60,15 @@ const CommentSectionV2 = ({ sourceId }: CommentsV2Props) => { highlightedReply.highlighted = true } } + + // ensure highlighted comment is visible + const index = comments.findIndex( + (x) => x.highlighted || x.replies?.some((y) => y.highlighted), + ) + + if (index > 5) { + setCommentLimit(index + 1) + } } setComments(comments || [])