Skip to content
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

fix: don't assign NSAlert to window which is not visible #23089

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/dialog.md
Expand Up @@ -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 `browserWindow` is not shown dialog will not be attached to it. In such case It will be displayed as independed window.
jkleinsc marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down
6 changes: 4 additions & 2 deletions shell/browser/ui/message_box_mac.mm
Expand Up @@ -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;
Expand Down