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 bugs around STPPaymentCardTextField becomeFirstResponder #855

Merged

Commits on Dec 13, 2017

  1. Fix bugs around STPPaymentCardTextField becomeFirstResponder

    Previous implementation of `nextFirstResponderField` would return `nil` if all fields were
    valid, which blocked programatic calls to `becomeFirstResponder`.
    
    It *also* used to cycle through the fields every time it was called, which doesn't seem
    right. It feels more natural for the `nextFirstResponderField` to be either the first
    invalid field *or* the last field. This puts the insertion point at the right place
    to start deleting.
    
    It also feels better if the user manually changes to the expiration field before entering
    the card number: once the expiration is valid the firstResponder jumps back to numbers.
    Then, once they complete numbers, it jumps to the CVC.
    
    I also added a test for this behavior. Some of the things it verifies:
    
    * becomeFirstResponder should not change the current first responder if the current field isn't valid yet
    * becomeFirstResponder should take the user to the first invalid field when called
    * becomeFirstResponder should make the last sub-field first responder when all the fields are valid
    danj-stripe committed Dec 13, 2017
    Configuration menu
    Copy the full SHA
    0ab8d0b View commit details
    Browse the repository at this point in the history
  2. Fix regression: nextFirstResponderField *should* prefer to go to th…

    …e next field, even if others are invalid
    
    It's good to have the explicit progression through fields. Keep the previous behavior that
    when they're on the last field and finish filling it out, take them back to the first
    invalid field.
    
    Also, update `canBecomeFirstResponder` and `becomeFirstResponder` to *never* change which
    field is the first responder, if one of the subfields already is. If there isn't one,
    use either the first invalid field or the last field.
    
    Updates tests to reflect the new expected behavior.
    danj-stripe committed Dec 13, 2017
    Configuration menu
    Copy the full SHA
    65c952b View commit details
    Browse the repository at this point in the history