Skip to content

Commit

Permalink
feat: disable "Changes you made may not be saved." prompt in dev mode (
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
dsmmcken committed Feb 6, 2024
1 parent ffd1e7b commit 6b0dce1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/code-studio/src/main/AppMainContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 6b0dce1

Please sign in to comment.