Skip to content

Commit

Permalink
Fix keyboard handling with keyboardShouldPersistTaps: never
Browse files Browse the repository at this point in the history
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 facebook#19255

Differential Revision: D8002818

Pulled By: mdvacca

fbshipit-source-id: 6ecb8d2c30eb9338529471a958b5dc04037c7ec6
  • Loading branch information
janicduplessis authored and macdoum1 committed Jun 28, 2018
1 parent 2e3913f commit e347fa9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Libraries/Components/ScrollResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e347fa9

Please sign in to comment.