Skip to content

Dialogs aren't centered to the window when calling showMessageBox(win, ...) #23001

@pushkin-

Description

@pushkin-

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version: 8.2.0
  • Operating System: Windows 10 (version 1709)
  • Last Known Working Electron version: not sure

Expected Behavior

I expect that opening a dialog via dialog.showMessageBox(...) and passing in a window as the first argument will create a dialog that's centered to the window.

Actual Behavior

The dialog is centered to the screen.

To Reproduce

Run the app below and observe that the dialog isn't centered to the window.

const { app, BrowserWindow, dialog } = require('electron')

async function createWindow() {
  const mainWindow = new BrowserWindow({ x: 1000, y: 1000 });
  await mainWindow.loadURL("https://google.com");

  dialog.showMessageBox(mainWindow, {
    message: "message"
  });
}

app.on('ready', createWindow)

It's not clear whether this is a bug or a feature request.

A similar issue here suggests that centering to the window is the expected behavior when using showMessageBox(win, ...):

If you want to center the dialog in a window, you should use showMessageBox and pass the window to it.

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions