Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions front_end/src/components/comment_feed/comment_card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Props = {
keyFactorVotesScore: number;
className?: string;
expandOverride?: "auto" | "expanded" | "collapsed";
onViewComment?: () => void;
commentUrl?: string;
disableVoting?: boolean;
collapsedHeight?: number;
};
Expand Down Expand Up @@ -84,14 +84,14 @@ const ExpandableCommentContent = ({
isExpanded,
needsExpand,
contentRef,
onViewComment,
commentUrl,
collapsedHeight,
}: {
comment: BECommentType;
isExpanded: boolean;
needsExpand: boolean;
contentRef: React.RefObject<HTMLDivElement | null>;
onViewComment?: () => void;
commentUrl?: string;
collapsedHeight: number;
}) => {
const locale = useLocale();
Expand Down Expand Up @@ -125,10 +125,12 @@ const ExpandableCommentContent = ({
})}
</span>
</div>
{onViewComment && (
{commentUrl && (
<Button
variant="text"
onClick={onViewComment}
href={commentUrl}
target="_blank"
rel="noopener noreferrer"
size="sm"
className="gap-2 border-none px-2.5 py-1 font-normal text-blue-700 dark:text-blue-700-dark"
>
Expand Down Expand Up @@ -177,7 +179,7 @@ const CommentCard: FC<Props> = ({
changedMyMindCount,
keyFactorVotesScore,
expandOverride = "auto",
onViewComment,
commentUrl,
disableVoting = false,
collapsedHeight = DEFAULT_collapsedHeight,
}) => {
Expand Down Expand Up @@ -278,7 +280,7 @@ const CommentCard: FC<Props> = ({
isExpanded={effectiveExpanded}
needsExpand={needsExpand}
contentRef={contentRef}
onViewComment={onViewComment}
commentUrl={commentUrl}
collapsedHeight={collapsedHeight}
/>

Expand Down
11 changes: 3 additions & 8 deletions front_end/src/components/comment_feed/comment_feed_card.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { FC, memo, useCallback } from "react";
import { FC, memo } from "react";

import CommentCard from "@/components/comment_feed/comment_card";
import CommentPostPreview from "@/components/comment_feed/comment_post_preview";
Expand All @@ -14,12 +14,7 @@ type Props = {
};

const CommentFeedCard: FC<Props> = ({ comment, post }) => {
const handleViewComment = useCallback(() => {
window.open(
`/questions/${comment.on_post}/#comment-${comment.id}`,
"_blank"
);
}, [comment.on_post, comment.id]);
const commentUrl = `/questions/${comment.on_post}/#comment-${comment.id}`;

return (
<div
Expand Down Expand Up @@ -48,7 +43,7 @@ const CommentFeedCard: FC<Props> = ({ comment, post }) => {
className="mt-0 border-none dark:border-none md:mt-0"
expandOverride="collapsed"
collapsedHeight={222}
onViewComment={handleViewComment}
commentUrl={commentUrl}
/>
</div>
</div>
Expand Down
Loading