Fix parent comment linking when not showing context (#2417)

The same code is reused for the "show context" button as for the "link
to self" button. I'm not sure that's such a good idea in the long run.

There was a const `parentCommentId` that was always set even when not
having the `showContext` prop, causing the bug #2401.
This commit is contained in:
snan 2024-04-11 14:58:23 +02:00 committed by GitHub
parent ddd4a98fd7
commit b983071e79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -501,14 +501,14 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
? I18NextService.i18n.t("show_context")
: I18NextService.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/${parentCommentId}`}
to={`/comment/${
(this.props.showContext && getCommentParentId(cv.comment)) ||
cv.comment.id
}`}
title={title}
>
<Icon icon="link" classes="icon-inline" />