mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: don't assign NSAlert to window which is not visible (#23089)
* fix: don't assign NSAlert to window which is not visible Without this change it's possible to create message box which can't be dismissed on mac. * fixup! fix: don't assign NSAlert to window which is not visible * fixup! fix: don't assign NSAlert to window which is not visible * Update docs/api/dialog.md Co-authored-by: Cezary Kulakowski <cezary@openfin.co> Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
This commit is contained in:
@@ -254,6 +254,7 @@ Shows a message box, it will block the process until the message box is closed.
|
||||
It returns the index of the clicked button.
|
||||
|
||||
The `browserWindow` argument allows the dialog to attach itself to a parent window, making it modal.
|
||||
If the `browserWindow` is not shown, the dialog will not be attached to it. In that case it will be displayed as an independent window.
|
||||
|
||||
### `dialog.showMessageBox([browserWindow, ]options)`
|
||||
|
||||
|
||||
@@ -97,8 +97,10 @@ int ShowMessageBoxSync(const MessageBoxSettings& settings) {
|
||||
NSAlert* alert = CreateNSAlert(settings);
|
||||
|
||||
// Use runModal for synchronous alert without parent, since we don't have a
|
||||
// window to wait for.
|
||||
if (!settings.parent_window)
|
||||
// window to wait for. Also use it when window is provided but it is not
|
||||
// shown as it would be impossible to dismiss the alert if it is connected
|
||||
// to invisible window (see #22671).
|
||||
if (!settings.parent_window || !settings.parent_window->IsVisible())
|
||||
return [[alert autorelease] runModal];
|
||||
|
||||
__block int ret_code = -1;
|
||||
|
||||
Reference in New Issue
Block a user