fix: changing the title and body content in quick succession would trigger unsaved changes warning prompt (#2950)

changing the title and body content in quick succession would trigger unsaved changes warning prompt
This commit is contained in:
Nan Yu authored and GitHub committed 2022-01-19 12:57:44 -08:00
1 parent d0e7f2de65
commit 8bced69828
2 files changed
+15 -3

No files matched your search

+14 -3
View File
@@ -466,9 +466,20 @@ class DocumentScene extends React.Component<Props> {
!this.isUploading &&
!team?.collaborativeEditing
}
message={t(
`You have unsaved changes.\nAre you sure you want to discard them?`
)}
message={(location, action) => {
if (
// a URL replace matching the current document indicates a title change
// no guard is needed for this transition
action === "REPLACE" &&
location.pathname === editDocumentUrl(document)
) {
return true;
}
return t(
`You have unsaved changes.\nAre you sure you want to discard them?`
) as string;
}}
/>
<Prompt
when={this.isUploading && !this.isEditorDirty}
@@ -40,6 +40,7 @@
"Dark": "Dark",
"Light": "Light",
"System": "System",
"Appearance": "Appearance",
"Change theme": "Change theme",
"Change theme to": "Change theme to",
"Invite people": "Invite people",