]> Untitled Git - lemmy-ui.git/commitdiff
Show parent comment for comment link. Fixes #1030 (#1032)
authorDessalines <dessalines@users.noreply.github.com>
Mon, 22 May 2023 01:30:13 +0000 (21:30 -0400)
committerGitHub <noreply@github.com>
Mon, 22 May 2023 01:30:13 +0000 (21:30 -0400)
* Show parent comment for comment link. Fixes #1030

* Changing let to const.

src/shared/components/comment/comment-node.tsx

index 16e0a731640f017e235c0ed9ae83e6138e5a4f7a..d2dee1e87d522996271035bdc92d5d5c6f7bacf8 100644 (file)
@@ -42,6 +42,7 @@ import {
   colorList,
   commentTreeMaxDepth,
   futureDaysToUnixTime,
+  getCommentParentId,
   isAdmin,
   isBanned,
   isMod,
@@ -1051,11 +1052,14 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
       ? i18n.t("show_context")
       : i18n.t("link");
 
+    // The context button should show the parent comment by default
+    const parentCommentId = getCommentParentId(cv.comment) ?? cv.comment.id;
+
     return (
       <>
         <Link
           className={classnames}
-          to={`/comment/${cv.comment.id}`}
+          to={`/comment/${parentCommentId}`}
           title={title}
         >
           <Icon icon="link" classes="icon-inline" />