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

Unified Diff: chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller.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 | « no previous file | chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller.mm
diff --git a/chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller.mm b/chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller.mm
index b1a40b565a2d6334e2b40790f8fecd6154d43b5b..e0f79117ee809061763143505ea2b34b7d03f095 100644
--- a/chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller.mm
@@ -109,11 +109,17 @@ initWithChooserDialogCocoa:(ChooserDialogCocoa*)chooserDialogCocoa
}
- (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 | « no previous file | chrome/browser/ui/cocoa/extensions/chooser_dialog_cocoa_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698