From 5dad02ac0df192545cbb7c5475bc1e24a69d5846 Mon Sep 17 00:00:00 2001 From: Artem <39980963+SnaiNeR@users.noreply.github.com> Date: Wed, 10 Jun 2020 14:25:22 +0500 Subject: [PATCH] Do not animate layout if keyboard state is not changed https://github.com/Andr3wHur5t/react-native-keyboard-spacer/pull/66 I've found that closing a modal cause keyboard to open and then immediately hide, which causes multiple calls of resetKeyboardSpace function, and this causes an error: Warning: Overriding previous layout animation Which affects Modal somehow, because it could not be hidden after this warning. --- KeyboardSpacer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/KeyboardSpacer.js b/KeyboardSpacer.js index 6200984..4d5e0ac 100644 --- a/KeyboardSpacer.js +++ b/KeyboardSpacer.js @@ -86,7 +86,7 @@ export default class KeyboardSpacer extends Component { } updateKeyboardSpace(event) { - if (!event.endCoordinates) { + if (!event.endCoordinates || this.state.isKeyboardOpened) { return; } @@ -113,6 +113,10 @@ export default class KeyboardSpacer extends Component { } resetKeyboardSpace(event) { + if (!this.state.isKeyboardOpened) { + return; + } + let animationConfig = defaultAnimation; if (Platform.OS === 'ios') { animationConfig = LayoutAnimation.create(