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
2022-01-19 12:57:44 -08:00
committed by GitHub
parent d0e7f2de65
commit 8bced69828
2 changed files with 15 additions and 3 deletions

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}