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

Scroll bug when presenting addCardViewController #942

Closed
Klingefjord opened this issue May 22, 2018 · 5 comments
Closed

Scroll bug when presenting addCardViewController #942

Klingefjord opened this issue May 22, 2018 · 5 comments

Comments

@Klingefjord
Copy link

Summary

Scroll bug on addCardViewController. When textfield becomes first responder, the view scrolls autmoatically so that the card animation goes underneath the navigation bar

Code to reproduce

This is what I use to present the addCardViewController:

    func initializeStripe(_ sender: UIViewController, key: String) {
        let addCardViewController = STPAddCardViewController(configuration: StripeUtil.getPaymentConfiguration(key),
                                                             theme: StripeUtil.getTheme())
        addCardViewController.delegate = self
        sender.present(UINavigationController(rootViewController: addCardViewController), animated: true)
        }
    }

iOS version

11.3

Installation method

CocoaPods

SDK version

13.0.1

Other information

gid

@joeydong-stripe
Copy link
Contributor

Hi @Klingefjord, thanks for opening an issue and providing the gif.

This looks like the expected behavior as far as I know. The intended behavior is for the text field to be vertically center in the remaining space not taken up by the keyboard. As a result, the card can end up offscreen. What do you think?

Here is the code if you want to try experimenting with it:

https://github.com/stripe/stripe-ios/blob/master/Stripe/UIViewController%2BStripe_KeyboardAvoiding.m#L50-L60

One option is to stop calling stp_beginObservingKeyboardAndInsettingScrollView but that could become an issue in this particular case if the screen is shorter and the text field can end up behind the keyboard frame.

@Klingefjord
Copy link
Author

Personally I think the textfield shouldn't get centered as it looks especially weird during the card flip animation. Maybe some tweaking to the offset if the textfield is the first one underneath the card? I tried changing https://github.com/stripe/stripe-ios/blob/master/Stripe/UIViewController%2BStripe_KeyboardAvoiding.m#L111 to offset.y = ((topOfScreenOffset + topOfKeyboardOffset) / 2) - scrollView.contentInset.top - 70;, It looks like the following on iPhone 5 and iPhone 7:

skarmavbild 2018-05-23 kl 09 41 27

skarmavbild 2018-05-22 kl 10 08 57

@joeydong-stripe
Copy link
Contributor

Hi @Klingefjord

Thanks for taking a look, you were on the right track. We had a team discussion and decided to change our opinion and try to have the scroll view behave as natively as possible.

I just opened this pull request #943 and would love for you to try it out. As I mentioned in the pull request, we don't have too much context on how this class was implemented so we should invest extra time in testing the change.

@Klingefjord
Copy link
Author

Great! Tested your pr out, think it looks much better.
Big thanks for quick response!

@joeydong-stripe
Copy link
Contributor

👋 we just released v13.0.2 that includes this change. thanks for bringing it to our attention :)

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

No branches or pull requests

2 participants