Skip to content

Commit 7938e58

Browse files
committed
fix: allow CommentsListItem to be compiled
1 parent 349da36 commit 7938e58

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/sanity/src/core/comments/components/list/CommentsListItem.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ export const CommentsListItem = memo(function CommentsListItem(props: CommentsLi
144144
} = props
145145
const {t} = useTranslation(commentsLocaleNamespace)
146146
const [value, setValue] = useState<CommentMessage>(EMPTY_ARRAY)
147-
const [collapsed, setCollapsed] = useState<boolean>(true)
148-
const didExpand = useRef<boolean>(false)
147+
const [collapsed, setCollapsed] = useState(true)
148+
const [didExpand, setDidExpand] = useState(false)
149149
const replyInputRef = useRef<CommentInputHandle>(null)
150150

151151
const {isTopLayer} = useLayer()
@@ -238,7 +238,7 @@ export const CommentsListItem = memo(function CommentsListItem(props: CommentsLi
238238
const handleExpand = useCallback((e: MouseEvent<HTMLButtonElement>) => {
239239
e.stopPropagation()
240240
setCollapsed(false)
241-
didExpand.current = true
241+
setDidExpand(true)
242242
}, [])
243243

244244
const splicedReplies = useMemo(() => {
@@ -258,10 +258,10 @@ export const CommentsListItem = memo(function CommentsListItem(props: CommentsLi
258258
}, [replies?.length])
259259

260260
useEffect(() => {
261-
if (replies.length > MAX_COLLAPSED_REPLIES && !didExpand.current) {
261+
if (replies.length > MAX_COLLAPSED_REPLIES && !didExpand) {
262262
setCollapsed(true)
263263
}
264-
}, [replies])
264+
}, [replies, didExpand])
265265

266266
const renderedReplies = useMemo(
267267
() =>
@@ -356,7 +356,7 @@ export const CommentsListItem = memo(function CommentsListItem(props: CommentsLi
356356
/>
357357
</Stack>
358358

359-
{showCollapseButton && !didExpand.current && (
359+
{showCollapseButton && !didExpand && (
360360
<Flex gap={1} paddingY={1} sizing="border">
361361
<SpacerAvatar />
362362

0 commit comments

Comments
 (0)