diff --git a/lib/browser/api/dialog.js b/lib/browser/api/dialog.js index 861f0a0d0646b..7659800b79b21 100644 --- a/lib/browser/api/dialog.js +++ b/lib/browser/api/dialog.js @@ -263,7 +263,8 @@ module.exports = { // Choose a default button to get selected when dialog is cancelled. if (cancelId == null) { - cancelId = 0 + // If the defaultId is set to 0, ensure the cancel button is a different index (1) + cancelId = (defaultId === 0 && buttons.length > 1) ? 1 : 0 for (let i = 0; i < buttons.length; i++) { const text = buttons[i].toLowerCase() if (text === 'cancel' || text === 'no') {