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 issue with country dropdown not updating country #5431
Fix issue with country dropdown not updating country #5431
Conversation
Diffuse output:
APK
DEX
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix looks good to me. Added two small comments.
@@ -68,6 +68,12 @@ open class AddressElement constructor( | |||
addressRepository.get(countryCode) | |||
?: emptyList() | |||
} | |||
.map { fields -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of mapping, you could use an onEach { … }
here. I find it shows the side-effect-y intention better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
addressElement.fields.first().map { | ||
it.getFormFieldValueFlow().first()[0].second.value | ||
}.first() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you end up just using the first element from the mapped list, you could avoid mapping the entire list and just access the first element directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Summary
Fix an issue where the country dropdown was not updating correctly. This was broken in this previous PR
To test the change, use the payment sheet playground and play around with different customer types, default billing address enabled/disabled, and update the country dropdown to different countries. Make sure that the fields get updated, for example, US should show zip code, Canada should show postal code, other countries may not have other fields for billing address.
Testing
Screenshots