mirror of
https://github.com/outline/outline.git
synced 2026-11-26 07:33:19 +03:00
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:
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
|
||||
|
||||
Reference in new issue
Block a user