perf: move comment composer selection timer cleanup to ref (#4082)

This commit is contained in:
Neil 2026-05-31 03:42:33 -07:00 committed by GitHub
parent 81e850d0af
commit 7677f71a7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 3 deletions

View File

@ -101,8 +101,13 @@ export function RightPanelCommentComposer({
return () => clearRightPanelCommentFocusTimer(autoFocusTimerRef)
}, [autoFocus])
useEffect(() => {
return () => clearRightPanelCommentFocusTimer(selectionTimerRef)
const setTextareaRef = useCallback((node: HTMLTextAreaElement | null) => {
textareaRef.current = node
if (node === null) {
// Why: markdown toolbar selection restoration is scoped to this textarea;
// clearing here prevents stale focus after the composer unmounts.
clearRightPanelCommentFocusTimer(selectionTimerRef)
}
}, [])
const stopPropagation = useCallback((event: React.SyntheticEvent) => {
@ -176,7 +181,7 @@ export function RightPanelCommentComposer({
onMouseDown={stopPropagation}
>
<textarea
ref={textareaRef}
ref={setTextareaRef}
value={body}
rows={3}
className="block max-h-44 min-h-20 w-full min-w-0 resize-none bg-transparent px-2.5 py-2 text-[12px] leading-relaxed text-foreground outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-60"