-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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 ReactEditText so it works with Android Emoji2 automatic support #33920
Conversation
Base commit: 91452fc |
jump |
No clue why that many tests all failed to run for that change, but happy to rebase on latest or whatever is needed. |
Code looks good to me. |
5752967
to
fcde652
Compare
Awesome, thanks!
Haha, the distance is about the length of time I was waiting for the CLA to be signed, lol. Done! |
Base commit: 91452fc |
@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This pull request was successfully merged by Andy Zolyak in 92ebb29. When will my fix make it into a release? | Upcoming Releases |
Summary
tldr;
ReactEditText
and Android's emoji support in Android's AppCompat 1.4.0 / 1.4.x conflict in an odd way, causing NPEs.ReactEditText
defines anInternalKeyListener
,mKeyListener
, that it uses to make sure input from all keyboards works correctly. This listener is normally initialized at the end of the constructor.Unfortunately, some versions of
AppCompatEditText
, most notably the version in the App Compat1.4.0-alpha0x
, the minimum version required for the Play Store's emoji compliance callsetInputType
fromAppCompatEditText
's constructor.ReactEditText
operates on the key listener inside ofsetInputType
and since theAppCompatEditText
constructor is called via call tosuper
before the key listener is initialized, these versions of app compat can cause NPEs when used with React Native.The fix is simple; check to see if
mKeyListener
is null, and initialize it if it is. This is necessary in both the constructor and inside ofsetInputType
.Changelog
https://github.com/facebook/react-native/wiki/Changelog
[Android] [Fixed] - NPE in
ReactEditText.setInputType
when React Native is used with some versions of a AppCompat 1.4.x. (and possibly others)Test Plan
If you're working from this branch, you'll be fine. If you're working from main you'll get an NPE.
I can put together a test repo if needed.