Skip to content

Commit cb55bc5

Browse files
authoredMar 18, 2024
fix(comments): hide context menu actions if handler is undefined (#6011)
1 parent c105115 commit cb55bc5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed
 

‎packages/sanity/src/structure/comments/src/components/list/CommentsListItemContextMenu.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export function CommentsListItemContextMenu(props: CommentsListItemContextMenuPr
110110
icon={status === 'open' ? CheckmarkCircleIcon : UndoIcon}
111111
mode="bleed"
112112
onClick={onStatusChange}
113+
hidden={!onStatusChange}
113114
tooltipProps={{
114115
content:
115116
status === 'open'
@@ -118,6 +119,7 @@ export function CommentsListItemContextMenu(props: CommentsListItemContextMenuPr
118119
}}
119120
/>
120121
)}
122+
121123
{hasContextMenuOptions && (
122124
<MenuButton
123125
id="comment-actions-menu"
@@ -151,7 +153,7 @@ export function CommentsListItemContextMenu(props: CommentsListItemContextMenuPr
151153
tone="critical"
152154
/>
153155

154-
<MenuDivider hidden={!canDelete && !canEdit} />
156+
{onCopyLink && <MenuDivider hidden={!canDelete && !canEdit} />}
155157

156158
<MenuItem
157159
hidden={!onCopyLink}

‎packages/sanity/src/structure/comments/src/components/list/CommentsListItemLayout.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable complexity */
12
import {hues} from '@sanity/color'
23
import {type CurrentUser} from '@sanity/types'
34
import {
@@ -412,13 +413,13 @@ export function CommentsListItemLayout(props: CommentsListItemLayoutProps) {
412413
canEdit={canEdit}
413414
isParent={isParent}
414415
mode={mode}
415-
onCopyLink={handleCopyLink}
416+
onCopyLink={onCopyLink ? handleCopyLink : undefined}
416417
onDeleteStart={handleDelete}
417418
onEditStart={toggleEdit}
418419
onMenuClose={handleMenuClose}
419420
onMenuOpen={handleMenuOpen}
420421
onReactionSelect={handleReactionSelect}
421-
onStatusChange={handleOpenStatusChange}
422+
onStatusChange={onStatusChange ? handleOpenStatusChange : undefined}
422423
readOnly={readOnly}
423424
status={comment.status}
424425
/>

0 commit comments

Comments
 (0)
Please sign in to comment.