X Tutup
Skip to content

Commit 97010bf

Browse files
trop[bot]CezaryKulakowskiJohn Kleinschmidt
authored
fix: don't assign NSAlert to window which is not visible (electron#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>
1 parent 372c5b9 commit 97010bf

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/api/dialog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ Shows a message box, it will block the process until the message box is closed.
254254
It returns the index of the clicked button.
255255

256256
The `browserWindow` argument allows the dialog to attach itself to a parent window, making it modal.
257+
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.
257258

258259
### `dialog.showMessageBox([browserWindow, ]options)`
259260

shell/browser/ui/message_box_mac.mm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ int ShowMessageBoxSync(const MessageBoxSettings& settings) {
9797
NSAlert* alert = CreateNSAlert(settings);
9898

9999
// Use runModal for synchronous alert without parent, since we don't have a
100-
// window to wait for.
101-
if (!settings.parent_window)
100+
// window to wait for. Also use it when window is provided but it is not
101+
// shown as it would be impossible to dismiss the alert if it is connected
102+
// to invisible window (see #22671).
103+
if (!settings.parent_window || !settings.parent_window->IsVisible())
102104
return [[alert autorelease] runModal];
103105

104106
__block int ret_code = -1;

0 commit comments

Comments
 (0)
X Tutup