From 36f7974e188a649d0a9a27fd1d242454d8ff17d1 Mon Sep 17 00:00:00 2001 From: "trop[bot]" Date: Wed, 27 Feb 2019 10:10:18 -0800 Subject: [PATCH] fix: set cancelId to 1 when defaultId == 0 and no 'cancel' button (#17149) --- lib/browser/api/dialog.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/browser/api/dialog.js b/lib/browser/api/dialog.js index d7545a7687a..279f1cd848f 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') {