Skip to content

Disable beforeUnload during app mode #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/ide/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ export abstract class IdeClient {

let appWindow: Window | undefined;

window.addEventListener("beforeunload", (e) => {
e.preventDefault(); // FireFox
e.returnValue = ""; // Chrome
});
if (!window.matchMedia("(display-mode: standalone)").matches) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't match fullscreen. Is there a cleaner way to check if we're in a minified window mode?

https://developer.mozilla.org/en-US/docs/Web/CSS/@media/display-mode#Syntax

Copy link
Contributor Author

@nol166 nol166 Apr 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fullscreen mode would still have the problem where control + w closes the browser window, correct?

window.addEventListener("beforeunload", (e) => {
e.preventDefault(); // FireFox
e.returnValue = ""; // Chrome
});
}


window.addEventListener("message", (event) => {
if (event.data === "app") {
Expand Down