Fix keyboard handling with keyboardShouldPersistTaps: never

Summary:
When `keyboardShouldPersistTaps` is `"never"` it would break when doing the following steps:

- Tap input 1, keyboard goes up
- Tap input 2, keyboard stays down (The bug I expected without the isTextInput check was that it would dismiss instead :o )
- Tap outside, keyboard stays down. It should dismiss here since it should never persist taps (unless tapping another input)

What seems to happen is that RN `currentlyFocusedTextInput` goes out of sync with the focused text input and is null even if there is still a text input focused. I haven't had time to investigate the cause of that (probably some race condition because of trying to focus and blur at the same time) but we should not try to dismiss the keyboard when tapping another TextInput in the first place.

I reproduced the bug mentioned by setting `keyboardShouldPersistTaps` to `"never"` in RNTesterPage.js and then using the steps described above. I made sure that the bug did not happen after this change.

[GENERAL][BUGFIX][ScrollResponder] - Fix keyboard handling with keyboardShouldPersistTaps: never
Closes https://github.com/facebook/react-native/pull/19255

Differential Revision: D8002818

Pulled By: mdvacca

fbshipit-source-id: 6ecb8d2c30eb9338529471a958b5dc04037c7ec6
This commit is contained in:
Janic Duplessis 2018-05-14 23:30:53 -07:00 committed by Facebook Github Bot
parent 42fc87eb8d
commit ffe6c110f7
1 changed files with 2 additions and 2 deletions

View File

@ -207,8 +207,8 @@ const ScrollResponderMixin = {
!keyboardShouldPersistTaps || keyboardShouldPersistTaps === 'never';
if (
keyboardNeverPersistTaps &&
currentlyFocusedTextInput != null
/* && !TextInputState.isTextInput(e.target) */
currentlyFocusedTextInput != null &&
!TextInputState.isTextInput(e.target)
) {
return true;
}