fix: Empty drafts are not correctly cleared on tab quit (#11899)

dquote> fix: Existing drafts should not focus the editor
This commit is contained in:
Tom Moor authored and GitHub committed 2026-03-29 10:36:43 -04:00
1 parent 4b16545b10
commit 33b9a52dfe
1 file changed
+9 -2
@@ -103,6 +103,11 @@ function CommentForm({
useOnClickOutside(formRef, reset);
React.useEffect(() => {
window.addEventListener("beforeunload", reset);
return () => window.removeEventListener("beforeunload", reset);
}, [reset]);
const handleCreateComment = action(async (event: React.FormEvent) => {
event.preventDefault();
@@ -254,11 +259,13 @@ function CommentForm({
const handleMounted = React.useCallback(
(ref) => {
if (autoFocus && ref && !hasFocusedOnMount.current) {
ref.focusAtStart();
if (!draft) {
ref.focusAtStart();
}
hasFocusedOnMount.current = true;
}
},
[autoFocus]
[autoFocus, draft]
);
const presence = animatePresence