Fix reply cancellation clearing the wrong comment's reply box

When multiple comment threads had reply boxes open, cancelling one
reply cleared replyingCommentId unconditionally, closing whichever
box was open instead of the one actually cancelled. onCancelReply now
threads through the specific commentId so cancellation only clears
state if it matches the currently open reply.
This commit is contained in:
Jinjing
2026-07-13 15:45:22 -07:00
parent 06355d4a9e
commit edfa672532
@@ -1980,7 +1980,7 @@ function PRCommentGroupView({
presentation: PRCommentPresentationClasses
onResolve?: (threadId: string, resolve: boolean) => boolean | Promise<boolean>
onStartReply?: (commentId: number) => void
onCancelReply?: () => void
onCancelReply?: (commentId: number) => void
onReply?: (comment: PRComment, body: string) => Promise<RightPanelCommentSubmitResult>
onEditComment?: (comment: PRComment, body: string) => Promise<boolean>
onDeleteComment?: (comment: PRComment) => void | Promise<void>
@@ -2001,7 +2001,7 @@ function PRCommentGroupView({
autoFocus
disabled={replyDisabled}
disabledReason={replyDisabledReason}
onCancel={onCancelReply}
onCancel={() => onCancelReply?.(comment.id)}
onSubmit={(body) => onReply(comment, body)}
/>
</div>
@@ -2113,7 +2113,7 @@ function ResolvedCommentGroupsSection({
presentation: PRCommentPresentationClasses
onResolve?: (threadId: string, resolve: boolean) => boolean | Promise<boolean>
onStartReply?: (commentId: number) => void
onCancelReply?: () => void
onCancelReply?: (commentId: number) => void
onReply?: (comment: PRComment, body: string) => Promise<RightPanelCommentSubmitResult>
onEditComment?: (comment: PRComment, body: string) => Promise<boolean>
onDeleteComment?: (comment: PRComment) => void | Promise<void>
@@ -2351,7 +2351,9 @@ export function PRCommentsList({
presentation={presentation}
onResolve={onResolve}
onStartReply={setReplyingCommentId}
onCancelReply={() => setReplyingCommentId(null)}
onCancelReply={(commentId) =>
setReplyingCommentId((current) => (current === commentId ? null : current))
}
onReply={onReply}
onEditComment={onEditComment}
onDeleteComment={onDeleteComment}
@@ -2679,7 +2681,9 @@ export function PRCommentsList({
presentation={presentation}
onResolve={onResolve}
onStartReply={setReplyingCommentId}
onCancelReply={() => setReplyingCommentId(null)}
onCancelReply={(commentId) =>
setReplyingCommentId((current) => (current === commentId ? null : current))
}
onReply={onReply}
onEditComment={onEditComment}
onDeleteComment={onDeleteComment}