diff --git a/src/utils/startPrint.ts b/src/utils/startPrint.ts index 1c99bd3..938cf5e 100644 --- a/src/utils/startPrint.ts +++ b/src/utils/startPrint.ts @@ -28,6 +28,7 @@ export function startPrint(printWindow: HTMLIFrameElement, options: UseReactToPr print(printWindow) .then(() => { onAfterPrint?.(); + removePrintIframe(preserveAfterPrint); }) .catch((error: unknown) => { if (onPrintError) { @@ -38,9 +39,6 @@ export function startPrint(printWindow: HTMLIFrameElement, options: UseReactToPr suppressErrors, }); } - }) - .finally(() => { - removePrintIframe(preserveAfterPrint); }); } else { // Some browsers do not have a `.print` available, even though they should