Skip to content

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

TypeScript

Ask again before a reload after the signer comes back with the browser's Back button

Claude1bff11000650
diff --git a/src/components/signing/signing-live-shell.tsx b/src/components/signing/signing-live-shell.tsx
index 0033ea8..6136025 100644
--- a/src/components/signing/signing-live-shell.tsx
+++ b/src/components/signing/signing-live-shell.tsx
@@ -597,10 +597,21 @@ export function SigningLiveShell({
event.returnValue = " ";
}
+ // Coming back to this page with the browser's Back button (after a
+ // signing provider's redirect, say) restores it as it was left, so the
+ // signer is asked again before a later reload.
+ function askAgainOnReturn(event: PageTransitionEvent) {
+ if (event.persisted) {
+ leavingOnPurposeRef.current = false;
+ }
+ }
+
window.addEventListener("beforeunload", warnBeforeLeaving);
+ window.addEventListener("pageshow", askAgainOnReturn);
return () => {
window.removeEventListener("beforeunload", warnBeforeLeaving);
+ window.removeEventListener("pageshow", askAgainOnReturn);
};
}, [hasUnsubmittedEntries]);
// A group of radio buttons is one question: it is listed and counted once.