Skip to content

Commit a3c05cf

Browse files
nol166kylecarbs
authored andcommitted
Add confirmation for closing window (#463)
* Add confirmation for closing window * Make function an event listener for consistency * Change let to const * Refactor for compatability
1 parent 15ac5ac commit a3c05cf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/ide/src/client.ts

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ export abstract class IdeClient {
3434
this.loadTime = time(2500);
3535

3636
let appWindow: Window | undefined;
37+
38+
window.addEventListener("beforeunload", (e) => {
39+
e.preventDefault(); // FireFox
40+
e.returnValue = ""; // Chrome
41+
});
42+
3743
window.addEventListener("message", (event) => {
3844
if (event.data === "app") {
3945
appWindow = event.source as Window;

0 commit comments

Comments
 (0)