-
Notifications
You must be signed in to change notification settings - Fork 659
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 expiry date field issue in CardInputWidget
#5547
Conversation
CardInputWidget
Diffuse output:
APK
DEX
|
} | ||
} | ||
|
||
addTextChangedListener(textWatcher) |
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.
Thinking out loud: listenForDeleteEmpty()
is only called once in the constructor, so this is safe. If this constraint were to change, we wouldn't want to add multiple text watchers.
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.
Right, I added a check to make sure we only ever add this once. Just in case this is ever moved anywhere else.
c2642f6
to
34db268
Compare
@@ -86,6 +86,12 @@ open class StripeEditText @JvmOverloads constructor( | |||
|
|||
private var errorMessageListener: ErrorMessageListener? = null | |||
|
|||
private val isLastKeyDeleteTextWatcher = object : StripeTextWatcher() { |
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.
should we also add a test in StripeEditTextTest
?
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.
Added some!
2576cf9
to
10abb95
Compare
As mentioned in #5539, I've manually tested the version supplied and it fixes the problem for me (which I could previously reliably replicate) |
887b73e
to
f6da382
Compare
f6da382
to
b0b0bc6
Compare
Summary
This pull request fixes an issue in
CardInputWidget
that occurred on some devices, such as those from Samsung.A quick explanation: On the affected devices, the
StripeEditText
’sOnKeyListener
wasn’t called for all key presses, but only for presses of the backspace. With that, the class’sisLastKeyDelete
was alwaystrue
after a backspace press, resulting in theExpiryDateEditText
’s text not being updated.We’re adding a
TextWatcher
in addition to theOnKeyListener
to make sure that theisLastKeyDelete
property is always in the correct state.Also, we’re removing the
!isLastKeyDelete
condition inExpiryDateEditText
’safterTextChanged
. This condition prevented a behavior we actually want: If the current text is12 / 2
and the user presses backspace, we want to end up with12
instead of12 /
. This behavior was explicitly called out in a comment, but must have been broken some time ago.Motivation
Resolves: #5539
Testing
Screenshots
Changelog
[Fixed] Expiry dates in
CardInputWidget
,CardMultilineWidget
, andCardFormView
are no longer formatted incorrectly on certain devices.