Skip to content

Commit

Permalink
fix: Notification with reply obscuring first action on macOS (#37447)
Browse files Browse the repository at this point in the history
fix: Notification with reply obscuring first action

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed Mar 1, 2023
1 parent 87ec774 commit 7e02e1d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions shell/browser/notifications/mac/cocoa_notification.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,22 @@
[notification_ setSoundName:base::SysUTF16ToNSString(options.sound)];
}

[notification_ setHasActionButton:false];
if (options.has_reply) {
[notification_ setHasReplyButton:true];
[notification_ setResponsePlaceholder:base::SysUTF16ToNSString(
options.reply_placeholder)];
}

int i = 0;
action_index_ = UINT_MAX;
NSMutableArray* additionalActions =
[[[NSMutableArray alloc] init] autorelease];
for (const auto& action : options.actions) {
if (action.type == u"button") {
if (action_index_ == UINT_MAX) {
// If the notification has both a reply and actions,
// the reply takes precedence and the actions all
// become additional actions.
if (!options.has_reply && action_index_ == UINT_MAX) {
// First button observed is the displayed action
[notification_ setHasActionButton:true];
[notification_
Expand All @@ -86,16 +93,11 @@
}
i++;
}

if ([additionalActions count] > 0) {
[notification_ setAdditionalActions:additionalActions];
}

if (options.has_reply) {
[notification_ setResponsePlaceholder:base::SysUTF16ToNSString(
options.reply_placeholder)];
[notification_ setHasReplyButton:true];
}

if (!options.close_button_text.empty()) {
[notification_ setOtherButtonTitle:base::SysUTF16ToNSString(
options.close_button_text)];
Expand Down

0 comments on commit 7e02e1d

Please sign in to comment.