Commit 67eb8dd
committed
Fix ClassCastException in clearFocusAndMaybeRefocus when EditText is detached
On Android <= 9 (SDK_INT <= P) in touch mode, clearFocusAndMaybeRefocus
casts rootView to ViewGroup unconditionally. getRootView() returns the
view itself when the view is detached from the window, so an IME editor
action delivered over Binder that races the removal of the EditText from
the hierarchy crashes the app with:
java.lang.ClassCastException: com.facebook.react.views.textinput.ReactEditText
cannot be cast to android.view.ViewGroup
Use a safe cast and fall back to a plain clearFocus(): when the view is
already detached there is no focus to move, so the descendant-focusability
workaround is not needed.1 parent dfab628 commit 67eb8dd
1 file changed
Lines changed: 14 additions & 5 deletions
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput
Lines changed: 14 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
388 | 397 | | |
389 | 398 | | |
390 | 399 | | |
| |||
0 commit comments