Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3664)

Unified Diff: chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm

Issue 2054333002: Modify chooser controller to correctly handle removing item on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: modified chooser controller to correctly handle removing item on Mac Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller_unittest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm b/chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm
index 27602d31fc7a3444756d186eb1d071d3fb987816..93b445623d532f7df6e195003388c913be2a082a 100644
--- a/chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm
+++ b/chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm
@@ -252,11 +252,17 @@ std::unique_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() {
}
- (void)onOptionRemoved:(NSInteger)index {
- // |tableView_| will automatically selects the next item if the current
- // item is removed, so here it tracks if the removed item is the item
- // that was previously selected, if so, deselect it.
- if ([tableView_ selectedRow] == index)
+ // |tableView_| will automatically select the removed item's next item.
+ // So here it tracks if the removed item is the item that was currently
+ // selected, if so, deselect it. Also if the removed item is before the
+ // currently selected item, the currently selected item's index needs to
+ // be adjusted by one.
+ NSInteger selectedRow = [tableView_ selectedRow];
+ if (selectedRow == index)
[tableView_ deselectRow:index];
+ else if (selectedRow > index)
+ [tableView_ selectRowIndexes:[NSIndexSet indexSetWithIndex:selectedRow - 1]
+ byExtendingSelection:NO];
[self updateTableView];
}
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698