From 3749b78f629cd251c7c1aef66dc24f48cb9290aa Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 8 Oct 2026 20:50:55 -0400 Subject: [PATCH] fix: Log a warning instead of prompting when leaving a document with unsynced changes (#13994) --- app/scenes/Document/components/Document.tsx | 25 +++++++++++---------- shared/i18n/locales/en_US/translation.json | 2 -- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app/scenes/Document/components/Document.tsx b/app/scenes/Document/components/Document.tsx index a4dea7a5d9..35d9e996a3 100644 --- a/app/scenes/Document/components/Document.tsx +++ b/app/scenes/Document/components/Document.tsx @@ -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(); } }; diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 88c246f8ce..156d3a3942 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -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",