From 6b0dce168df01df02219f64dbd6f9b73eec1fb2a Mon Sep 17 00:00:00 2001 From: Don Date: Tue, 6 Feb 2024 11:41:53 -0500 Subject: [PATCH] feat: disable "Changes you made may not be saved." prompt in dev mode (#1775) When developing, the prompt to reload is a pretty annoying feature. I am not worried about lost query progress in dev mode, auto-refresh is more important. --- packages/code-studio/src/main/AppMainContainer.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/code-studio/src/main/AppMainContainer.tsx b/packages/code-studio/src/main/AppMainContainer.tsx index e79f11465..b2f88b6b2 100644 --- a/packages/code-studio/src/main/AppMainContainer.tsx +++ b/packages/code-studio/src/main/AppMainContainer.tsx @@ -165,11 +165,14 @@ export class AppMainContainer extends Component< AppMainContainerState > { static handleWindowBeforeUnload(event: BeforeUnloadEvent): void { - event.preventDefault(); - // returnValue is required for beforeReload event prompt - // https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#example - // eslint-disable-next-line no-param-reassign - event.returnValue = ''; + // in development, allow auto-reload + if (import.meta.env.PROD) { + event.preventDefault(); + // returnValue is required for beforeReload event prompt + // https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload#example + // eslint-disable-next-line no-param-reassign + event.returnValue = ''; + } } static hydrateConsole(