fix: Log a warning instead of prompting when leaving a document with unsynced changes (#13994)

This commit is contained in:
Tom Moor authored and GitHub committed 2026-10-08 20:50:55 -04:00
1 parent d6e555bb19
commit 3749b78f62
2 files changed
+13 -14

No files matched your search

+13 -12
View File
@@ -30,6 +30,7 @@ import { useLocationSidebarContext } from "~/hooks/useLocationSidebarContext";
import useMobile from "~/hooks/useMobile";
import useStores from "~/hooks/useStores";
import isTextInput from "~/utils/isTextInput";
import Logger from "~/utils/Logger";
import { client } from "~/utils/ApiClient";
import { emojiToUrl } from "~/utils/emoji";
import { documentHistoryPath, documentEditPath } from "~/utils/routeHelpers";
@@ -324,28 +325,28 @@ function DocumentScene({
const hasUnsyncedChanges = !readOnly && documentContext.hasUnsyncedChanges;
const warnUnsyncedChanges = () => {
Logger.warn("Leaving document with unsynced changes", {
documentId: document.id,
hasLocalPersistence: documentContext.hasLocalPersistence,
});
};
const handleBlockNavigation = () => {
if (hasUnsyncedChanges) {
return documentContext.hasLocalPersistence
? t(
`Your changes haven’t synced yet, they are saved on this device.\nAre you sure you want to leave?`
)
: t(
`Your changes haven’t synced yet and will be lost.\nAre you sure you want to leave?`
);
}
if (isUploading && !isEditorDirty) {
return t(
`Images are still uploading.\nAre you sure you want to discard them?`
);
}
if (hasUnsyncedChanges) {
warnUnsyncedChanges();
}
return true;
};
const handleUnload = (event: BeforeUnloadEvent) => {
const handleUnload = () => {
if (hasUnsyncedChanges) {
event.preventDefault();
event.returnValue = "";
warnUnsyncedChanges();
}
};
@@ -928,8 +928,6 @@
"Edits you make will sync once you’re online": "Edits you make will sync once you’re online",
"Offline": "Offline",
"Document restored": "Document restored",
"Your changes haven’t synced yet, they are saved on this device.\nAre you sure you want to leave?": "Your changes haven’t synced yet, they are saved on this device.\nAre you sure you want to leave?",
"Your changes haven’t synced yet and will be lost.\nAre you sure you want to leave?": "Your changes haven’t synced yet and will be lost.\nAre you sure you want to leave?",
"Images are still uploading.\nAre you sure you want to discard them?": "Images are still uploading.\nAre you sure you want to discard them?",
"{{ count }} comment": "{{ count }} comment",
"{{ count }} comment_plural": "{{ count }} comments",