Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cut-off payment methods carousel in payment sheet #5424

Merged
merged 3 commits into from Aug 19, 2022

Conversation

tillh-stripe
Copy link
Collaborator

@tillh-stripe tillh-stripe commented Aug 18, 2022

Summary

This pull request switches to using contentPadding for the payment methods carousel, which fixes a UX issue where the list was cut off prematurely at the start when scrolling.

Motivation

UX polish.

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screenshots

Before After
Scroll state at the beginning (nothing changed!) Screenshot_20220818_103916 Screenshot_20220818_103551
Scroll state at the end (padding fixed!) Screenshot_20220818_103403 Screenshot_20220818_103449

Changelog

Nothing to add.

@tillh-stripe tillh-stripe force-pushed the tillh/payments-list-padding-fix branch from a70aab9 to de53098 Compare August 18, 2022 14:44
@tillh-stripe tillh-stripe force-pushed the tillh/payments-list-padding-fix branch from de53098 to 03f61e8 Compare August 18, 2022 19:45
@@ -42,10 +44,10 @@ internal fun PaymentMethodsUI(
paymentMethods: List<SupportedPaymentMethod>,
selectedIndex: Int,
isEnabled: Boolean,
onItemSelectedListener: (SupportedPaymentMethod) -> Unit
onItemSelectedListener: (SupportedPaymentMethod) -> Unit,
state: LazyListState = rememberLazyListState()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulling this out so that I can pass in a specific firstVisibleItemIndex in tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this code below already scroll to have the selected item as the first visible?

LaunchedEffect(selectedIndex) {
    state.scrollToItem(selectedIndex, 0)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, you’re right. I initially thought that the LaunchedEffect didn’t work properly in the test, but turns out it was because I also passed a wrong selectedIndex in my test at the same time.

Copy link
Contributor

@jameswoo-stripe jameswoo-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -42,10 +44,10 @@ internal fun PaymentMethodsUI(
paymentMethods: List<SupportedPaymentMethod>,
selectedIndex: Int,
isEnabled: Boolean,
onItemSelectedListener: (SupportedPaymentMethod) -> Unit
onItemSelectedListener: (SupportedPaymentMethod) -> Unit,
state: LazyListState = rememberLazyListState()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this code below already scroll to have the selected item as the first visible?

LaunchedEffect(selectedIndex) {
    state.scrollToItem(selectedIndex, 0)
}

@tillh-stripe tillh-stripe force-pushed the tillh/payments-list-padding-fix branch from 991cef3 to d5b71c3 Compare August 19, 2022 18:47
Copy link
Contributor

@brnunes-stripe brnunes-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tillh-stripe tillh-stripe merged commit b459816 into master Aug 19, 2022
@tillh-stripe tillh-stripe deleted the tillh/payments-list-padding-fix branch August 19, 2022 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants