-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fixed confirmExit behaviour for Electron apps #6285
Conversation
The previous implementation did not work because the window was unloaded before the dialog could be opened. This implementation gets around some… unusual behaviour of Electron's beforeunload event by using the will-prevent-unload WebContents event. Signed-off-by: Matthew Gordon <matthew.gordon@arm.com>
I am verifying this... |
It works for me. See the commit hash and the behavior. Do not get me wrong, I do not mind switching to your solution, but I want to reproduce the problem fist. What should I do to not get notified before closing the application? Thanks! |
@kittaakos that's interesting, I can reproduce it every time. I have tried it on:
I start from a fresh Theia clone, then:
Then I follow the steps in the PR description. For what it's worth, here's Ubuntu 19.04 with One possible difference is that I use the close button in the title bar, but it also happens when I use the ALT-F4 shortcut. |
I will try it on my Windows image. |
The |
buttons: ['Yes', 'No'], | ||
title: 'Confirm', | ||
message: 'Are you sure you want to quit?', | ||
detail: 'Any unsaved changes will not be saved.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the default Chrome message is: https://github.com/eclipse-theia/theia/pull/6285/files#diff-b23416bfa30b320828382edc2ba8ea30L35
Do we want to align electron with Chome?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have verified it on my Windows image; it worked nicely.
Thank you for your contribution, @mcgordonite 👍
What it does
This PR restores the confirmation dialog shown in Electron mode when the user tries to exit without saving changes. On master, there is no confirmation, the app exits without saving.
This relates to an existing Electron issue: electron/electron#9966. Not opening a dialog in the beforeunload handler and using the will-prevent-unload event gets around this.
How to test
Start the Electron app then disable Auto Save. Either:
Then try:
In these cases, a confirmation dialog should be displayed.
In all other cases, the app should behave as before with no confirmation modal.
Review checklist
Reminder for reviewers