fix: android textinput gets blurred after navigating back

When navigating from ScreenA to ScreenB and then back to ScreenA,
react-navigation unconditionally calls `Keyboard.dismiss()`.
If the user is fast enough and taps on a `TextInput` after coming
back from ScreenB, the keyboard opens, just to be dismissed again.
This would also happen if some logic automatically focuses the
`TextInput` in ScreenA. This behaviour can be seen observed in
https://snack.expo.io/lTDZhVNhV.
This commit is contained in:
marhaupe
2020-10-30 16:52:49 +01:00
committed by Satyajit Sahoo
parent bf464a8378
commit 1169ed0946

View File

@@ -58,10 +58,12 @@ export default class KeyboardManager extends React.Component<Props> {
const input = this.previouslyFocusedTextInput;
if (Platform.OS === 'android') {
Keyboard.dismiss();
} else if (input) {
TextInput.State.blurTextInput(input);
if (input) {
if (Platform.OS === 'android') {
Keyboard.dismiss();
} else {
TextInput.State.blurTextInput(input);
}
}
// Cleanup the ID on successful page change