Skip to content

Open-source document signature platform. Not affiliated with DocuSign.

TypeScript

Save what is on screen if it changed while the save on the way out was pending

Claude6a5284dba9f9
diff --git a/src/components/envelopes/prepare-live-shell.tsx b/src/components/envelopes/prepare-live-shell.tsx
index 375d67a..040cdb1 100644
--- a/src/components/envelopes/prepare-live-shell.tsx
+++ b/src/components/envelopes/prepare-live-shell.tsx
@@ -617,6 +617,14 @@ function PrepareLiveShellContent({
fieldsRevisionRef.current = saved.fieldsRevision;
lastSavedSignatureRef.current = signature;
+
+ // A page shown again from the browser's cache may have been
+ // changed while this save was on its way, even back to the list
+ // saved before it, which autosave would have skipped. Save what
+ // is on screen so the server does not keep this older list.
+ if (serializeFieldRequest(currentFieldsRef.current) !== signature) {
+ void persistFieldsRef.current(currentFieldsRef.current);
+ }
} catch {
// The page has gone, or the save did not arrive: nothing to do.
}