From 5b48e03c7ccf9f598105d651dd6edf59b1a744c5 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Mon, 20 Aug 2018 02:11:03 +0530 Subject: [PATCH] fix: Dialog does not close on ESCAPE if defaultId is set (#14196) If defaultId is set, it was removing the key reference for the button at 0 which was previously set for the cancel_id --- atom/browser/ui/message_box_mac.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/atom/browser/ui/message_box_mac.mm b/atom/browser/ui/message_box_mac.mm index a29ebff7bead..ee2f59dc8c84 100644 --- a/atom/browser/ui/message_box_mac.mm +++ b/atom/browser/ui/message_box_mac.mm @@ -97,11 +97,6 @@ NSAlert* CreateNSAlert(NativeWindow* parent_window, NSArray* ns_buttons = [alert buttons]; int button_count = static_cast([ns_buttons count]); - // Bind cancel id button to escape key if there is more than one button - if (button_count > 1 && cancel_id >= 0 && cancel_id < button_count) { - [[ns_buttons objectAtIndex:cancel_id] setKeyEquivalent:@"\e"]; - } - if (default_id >= 0 && default_id < button_count) { // Focus the button at default_id if the user opted to do so. // The first button added gets set as the default selected. @@ -110,6 +105,11 @@ NSAlert* CreateNSAlert(NativeWindow* parent_window, [[ns_buttons objectAtIndex:default_id] setKeyEquivalent:@"\r"]; } + // Bind cancel id button to escape key if there is more than one button + if (button_count > 1 && cancel_id >= 0 && cancel_id < button_count) { + [[ns_buttons objectAtIndex:cancel_id] setKeyEquivalent:@"\e"]; + } + if (!checkbox_label.empty()) { alert.showsSuppressionButton = YES; alert.suppressionButton.title = base::SysUTF8ToNSString(checkbox_label);