webContents‘s will-prevent-unload event is helpless for true use #24994
Comments
|
I agree the API design is wrong. We should provide a callback to pass the result asynchronously. |
|
@zcbenz I'm new to contributing to Electron, so I'd like to work on this |
|
good |
|
@zcbenz @SimplyAhmazing Is anybody working on this issue now? If not, I would like to try this. |
|
@ashikvarma11 I attempted to work on this issue but got stuck as I don't have Electron development experience and couldn't figure out an existing pattern to model a solution for this. Feel free to take it. I'd also be happy to pair with you on it if you know how to do it and can impart some knowledge. |
|
Taking a look at this issue, I have some thoughts:
Digging through the code I do see that void ShowMessageBox(const MessageBoxSettings& settings,
MessageBoxCallback callback)It looks as though there is already a callback in this method that can be passed in that looks like this: typedef base::OnceCallback<void(int code, bool checkbox_checked)>
MessageBoxCallback;With this information, I'm not actually sure what the full ask is here. Any insight on this would be awesome! Thanks in advance :) |
|
@SimplyAhmazing If anyone has not taken this issue. I like to know how to do it. Please help |
|
Hello, what's the status of this? Is anyone working on it? I would love to give a helping hand! |
When developers use webContents‘s
will-prevent-unloadevent,They want to ask the user to confirm something most of the time.
Like this:
Actually,They can not use
dialog.showMessageBoxSync,because
dialog.showMessageBoxSyncis synchronous,It will block the main process event loop, and cause some unpredictable problems.
But They can not use the asynchronous method
dialog.showMessageBoxeither,because
dialog.showMessageBoxcan not prevent thewill-prevent-unloadeventCode:
The text was updated successfully, but these errors were encountered: