From 38a007e129e51dabcc21217b04e423416bd80b41 Mon Sep 17 00:00:00 2001 From: RSSfeed Date: Fri, 23 Mar 2018 10:16:01 +0100 Subject: [PATCH 1/2] only scroll back after keyboard hide if needed --- src/KeyboardAwareBase.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/KeyboardAwareBase.js b/src/KeyboardAwareBase.js index abc665f6..192dbfd4 100644 --- a/src/KeyboardAwareBase.js +++ b/src/KeyboardAwareBase.js @@ -115,7 +115,10 @@ export default class KeyboardAwareBase extends Component { const hasYOffset = this._keyboardAwareView && this._keyboardAwareView.contentOffset && this._keyboardAwareView.contentOffset.y !== undefined; const yOffset = hasYOffset ? Math.max(this._keyboardAwareView.contentOffset.y - keyboardHeight, 0) : 0; - this._keyboardAwareView.scrollTo({x: 0, y: yOffset, animated: true}); + + if ((yOffset - keyboardHeight) > 0) { + this.scrollToBottom(); + } } scrollBottomOnNextSizeChange() { From 377e88a293721a3e85aa8754821a2835983168d4 Mon Sep 17 00:00:00 2001 From: RSSfeed Date: Fri, 23 Mar 2018 10:23:28 +0100 Subject: [PATCH 2/2] also check keyboard hide because interactive keyboard dismiss will trigger event twice --- src/KeyboardAwareBase.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KeyboardAwareBase.js b/src/KeyboardAwareBase.js index 192dbfd4..698fc572 100644 --- a/src/KeyboardAwareBase.js +++ b/src/KeyboardAwareBase.js @@ -116,8 +116,8 @@ export default class KeyboardAwareBase extends Component { const hasYOffset = this._keyboardAwareView && this._keyboardAwareView.contentOffset && this._keyboardAwareView.contentOffset.y !== undefined; const yOffset = hasYOffset ? Math.max(this._keyboardAwareView.contentOffset.y - keyboardHeight, 0) : 0; - if ((yOffset - keyboardHeight) > 0) { - this.scrollToBottom(); + if ((yOffset - keyboardHeight) > 0 && keyboardHeight > 0) { + this.scrollToBottom(); } }