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

Unified Diff: ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm

Issue 2958823002: [Payment Request] Incomplete item shouldn't appear as selected when tapped. (Closed)
Patch Set: Addressed comments Created 3 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
Index: ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm
diff --git a/ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm b/ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm
index aee0278f710124c5aa00ecd6251db1d32cf52be8..339f5b5f84a193cd0f69325f62b1cae1148896f9 100644
--- a/ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm
+++ b/ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm
@@ -261,23 +261,25 @@ typedef NS_ENUM(NSInteger, ItemType) {
switch (item.type) {
case ItemTypeSelectableItem: {
- // Update the currently selected cell, if any.
- if (self.dataSource.selectedItemIndex != NSUIntegerMax) {
- DCHECK(self.dataSource.selectedItemIndex <
- [[self.dataSource selectableItems] count]);
- CollectionViewItem<PaymentsIsSelectable>* oldSelectedItem =
- [[self.dataSource selectableItems]
- objectAtIndex:self.dataSource.selectedItemIndex];
- oldSelectedItem.accessoryType = MDCCollectionViewCellAccessoryNone;
- [self reconfigureCellsForItems:@[ oldSelectedItem ]];
- }
-
- // Update the newly selected cell.
CollectionViewItem<PaymentsIsSelectable>* newSelectedItem =
reinterpret_cast<CollectionViewItem<PaymentsIsSelectable>*>(item);
- newSelectedItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark;
- [self reconfigureCellsForItems:@[ newSelectedItem ]];
-
+ // Update the currently selected and the newly selected cells only if the
+ // newly selected cell corresponds to a complete item and can be selected.
+ if (newSelectedItem.isComplete) {
+ // Update the currently selected cell, if any.
+ if (self.dataSource.selectedItemIndex != NSUIntegerMax) {
+ DCHECK(self.dataSource.selectedItemIndex <
+ [[self.dataSource selectableItems] count]);
+ CollectionViewItem<PaymentsIsSelectable>* oldSelectedItem =
+ [[self.dataSource selectableItems]
+ objectAtIndex:self.dataSource.selectedItemIndex];
+ oldSelectedItem.accessoryType = MDCCollectionViewCellAccessoryNone;
+ [self reconfigureCellsForItems:@[ oldSelectedItem ]];
+ }
+ // Update the newly selected cell.
+ newSelectedItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark;
+ [self reconfigureCellsForItems:@[ newSelectedItem ]];
+ }
// Notify the delegate of the selection.
NSUInteger index =
[self.collectionViewModel indexInItemTypeForIndexPath:indexPath];

Powered by Google App Engine
This is Rietveld 408576698