electron: dialog.showMessageBoxSync defaultId not work under windows OS.

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.0.0
  • Operating System:
    • Windows 10 (18362)
    • Ubuntu 14.04 x64
  • Last Known Working Electron version:

Expected Behavior

dialog.showMessageBoxSync(null, { type:'warning', buttons: ['Yes', 'No'], defaultId: 1, cancelId: 1, title: 'Power Control', message: "Warning!", }); I set “defaultId:1”, after executing the function,it should focus on the “No” button.

Actual Behavior

Execute the function, in windows 10, it focuses on the “Yes” button. And it focuses on the “No” button in Ubuntu 14.04.

To Reproduce

$ git clone git@github.com:ForJason/electron-smt.git
$ cd electron-smt
$ npm start

Screenshots

win10 ubuntu

Additional Information

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 2
  • Comments: 22 (6 by maintainers)

Most upvoted comments

Confirming that it still doesn’t work as expected

Property Value
Electron 19.0.4 and 19.0.5
OS Edition Windows 10 Pro
OS Version 21H2
OS build 19044.1766

The defaultId is simply ignored.

bump

bump

bump

On Fri, Oct 7, 2022, 10:20 PM github-actions[bot] @.***> wrote:

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, “bump”), and we’ll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron https://www.electronjs.org/releases/stable or in the beta https://www.electronjs.org/releases/beta—please include it with your comment!

— Reply to this email directly, view it on GitHub https://github.com/electron/electron/issues/22600#issuecomment-1272200363, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEPLHIZHN2GBUZTJCAV7XTWCDK77ANCNFSM4LEAHNBA . You are receiving this because you commented.Message ID: @.***>

I see defaultId working even with noLink: true.

This repros with Electron 12.0.1. If you explicitly set noLink to false, the issues goes away. Yes and No buttons seems to be defaulting to the no link display. If you change the labels, it will also work, but will look like this (which is where the noLink property comes in):

image