From df7f3577e6c18e392d24e825ab028520b1ccceec Mon Sep 17 00:00:00 2001 From: Ben Roth Date: Tue, 14 Jan 2020 15:27:04 -0800 Subject: [PATCH 1/2] fixes issue where disabling automatic scroll would also disable all keyboard avoiding behavior --- lib/KeyboardAwareHOC.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/KeyboardAwareHOC.js b/lib/KeyboardAwareHOC.js index 4bf0ed0..03dc6f2 100644 --- a/lib/KeyboardAwareHOC.js +++ b/lib/KeyboardAwareHOC.js @@ -362,7 +362,6 @@ function KeyboardAwareHOC( // Keyboard actions _updateKeyboardSpace = (frames: Object) => { // Automatically scroll to focused TextInput - if (this.props.enableAutomaticScroll) { let keyboardSpace: number = frames.endCoordinates.height + this.props.extraScrollHeight if (this.props.viewIsInsideTabBar) { @@ -392,7 +391,7 @@ function KeyboardAwareHOC( textInputBottomPosition > keyboardPosition - totalExtraHeight ) { - this._scrollToFocusedInputWithNodeHandle( + this.props.enableAutomaticScroll && this._scrollToFocusedInputWithNodeHandle( currentlyFocusedField ) } @@ -407,12 +406,12 @@ function KeyboardAwareHOC( keyboardSpace - (textInputBottomPosition - keyboardPosition) this.setState({ keyboardSpace }) - this.scrollForExtraHeightOnAndroid(totalExtraHeight) + this.props.enableAutomaticScroll && this.scrollForExtraHeightOnAndroid(totalExtraHeight) } else if ( textInputBottomPosition > keyboardPosition - totalExtraHeight ) { - this.scrollForExtraHeightOnAndroid( + this.props.enableAutomaticScroll && this.scrollForExtraHeightOnAndroid( totalExtraHeight - (keyboardPosition - textInputBottomPosition) ) @@ -423,7 +422,7 @@ function KeyboardAwareHOC( } } ) - } + if (!this.props.resetScrollToCoords) { if (!this.defaultResetScrollToCoords) { this.defaultResetScrollToCoords = this.position From e06d84335691215a4d98a773e15c0041a73e14ab Mon Sep 17 00:00:00 2001 From: Ben Roth Date: Thu, 30 Jul 2020 14:53:30 -0700 Subject: [PATCH 2/2] fixes issue measuring height on android --- lib/KeyboardAwareHOC.js | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/KeyboardAwareHOC.js b/lib/KeyboardAwareHOC.js index 03dc6f2..f682f1a 100644 --- a/lib/KeyboardAwareHOC.js +++ b/lib/KeyboardAwareHOC.js @@ -405,7 +405,7 @@ function KeyboardAwareHOC( keyboardSpace = keyboardSpace - (textInputBottomPosition - keyboardPosition) - this.setState({ keyboardSpace }) + // TODO: this wasn't working for castle: this.setState({ keyboardSpace }) this.props.enableAutomaticScroll && this.scrollForExtraHeightOnAndroid(totalExtraHeight) } else if ( textInputBottomPosition > diff --git a/package.json b/package.json index e5f3045..37d4bfc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "react-native-keyboard-aware-scroll-view", - "version": "0.9.1", + "name": "@castle-games/react-native-keyboard-aware-scroll-view", + "version": "0.9.2", "description": "A React Native ScrollView component that resizes when the keyboard appears.", "main": "index.js", "types": "index.d.ts",