Skip to content

Commit

Permalink
[iOS] Scrolling between the initial and expand states is jumpy
Browse files Browse the repository at this point in the history
Issue for the payments bottom sheet was caused by recalculating the
initial height every time -viewIsAppearing is called.

Keeping track of the value and reusing it fixed this issue.

Bug: 1469913
Change-Id: I64941cc7dc80473c3dd8414e0aa091be5f50037b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4771062
Reviewed-by: Tommy Martino <tmartino@chromium.org>
Commit-Queue: Veronique Nguyen <veronguyen@google.com>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1182618}
  • Loading branch information
Veronique Nguyen authored and Chromium LUCI CQ committed Aug 11, 2023
1 parent 18a3baf commit 69ca772
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ @interface PaymentsSuggestionBottomSheetViewController () <
// YES if the expanded bottom sheet size takes the whole screen.
@property(nonatomic, assign) BOOL expandSizeTooLarge;

// Keep track of the minimized state height.
@property(nonatomic, assign) absl::optional<CGFloat> minimizedStateHeight;

@end

@implementation PaymentsSuggestionBottomSheetViewController
Expand Down Expand Up @@ -133,6 +136,7 @@ - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {

if (self.traitCollection.preferredContentSizeCategory !=
previousTraitCollection.preferredContentSizeCategory) {
self.minimizedStateHeight = absl::nullopt;
[self updateHeight];
}
}
Expand All @@ -152,6 +156,13 @@ - (void)viewDidDisappear:(BOOL)animated {
[self.handler viewDidDisappear:animated];
}

- (CGFloat)initialHeight {
if (!self.minimizedStateHeight.has_value()) {
self.minimizedStateHeight = [super initialHeight];
}
return self.minimizedStateHeight.value();
}

#pragma mark - PaymentsSuggestionBottomSheetConsumer

- (void)setCreditCardData:
Expand Down

0 comments on commit 69ca772

Please sign in to comment.