perf: guard Linear comment footer async state without effect

This commit is contained in:
Neil
2026-05-30 02:00:23 -07:00
parent 916624a40d
commit a4bd225722
@@ -955,11 +955,10 @@ export function LinearIssueCommentFooter({
const textareaRef = useRef<HTMLTextAreaElement>(null)
const mountedRef = useRef(true)
useEffect(() => {
mountedRef.current = true
return () => {
mountedRef.current = false
}
const handleFooterRef = useCallback((node: HTMLDivElement | null): void => {
// Why: comment submission can resolve after the footer unmounts; the root
// ref keeps that completion from writing stale local state without an Effect.
mountedRef.current = node !== null
}, [])
const autoGrow = useCallback(() => {
@@ -1016,7 +1015,10 @@ export function LinearIssueCommentFooter({
if (variant === 'linear-page') {
return (
<div className="rounded-xl border border-border/70 bg-background shadow-xs">
<div
ref={handleFooterRef}
className="rounded-xl border border-border/70 bg-background shadow-xs"
>
<textarea
ref={textareaRef}
value={body}
@@ -1051,7 +1053,10 @@ export function LinearIssueCommentFooter({
}
return (
<div className="flex items-end gap-2 border-t border-border/60 bg-background/40 px-4 py-3">
<div
ref={handleFooterRef}
className="flex items-end gap-2 border-t border-border/60 bg-background/40 px-4 py-3"
>
<textarea
ref={textareaRef}
value={body}