Browse Source

fix: focus rings with multiple buttons in `showMessageBox` (#36802)

fix: focus rings with multiple buttons in messageBox

Co-authored-by: Shelley Vohr <[email protected]>

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <[email protected]>
trop[bot] 2 years ago
parent
commit
a35de7e89f
1 changed files with 5 additions and 3 deletions
  1. 5 3
      shell/browser/ui/message_box_mac.mm

+ 5 - 3
shell/browser/ui/message_box_mac.mm

@@ -71,9 +71,6 @@ NSAlert* CreateNSAlert(const MessageBoxSettings& settings) {
   int button_count = static_cast<int>([ns_buttons count]);
 
   if (settings.default_id >= 0 && settings.default_id < button_count) {
-    // Highlight the button at default_id
-    [[ns_buttons objectAtIndex:settings.default_id] highlight:YES];
-
     // The first button added gets set as the default selected, so remove
     // that and set the button @ default_id to be default.
     [[ns_buttons objectAtIndex:0] setKeyEquivalent:@""];
@@ -86,6 +83,11 @@ NSAlert* CreateNSAlert(const MessageBoxSettings& settings) {
     [[ns_buttons objectAtIndex:settings.cancel_id] setKeyEquivalent:@"\e"];
   }
 
+  // TODO(@codebytere): This behavior violates HIG & should be deprecated.
+  if (settings.cancel_id >= 0 && settings.cancel_id == settings.default_id) {
+    [[ns_buttons objectAtIndex:settings.default_id] highlight:YES];
+  }
+
   if (!settings.checkbox_label.empty()) {
     alert.showsSuppressionButton = YES;
     alert.suppressionButton.title =