Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where disabling automatic scroll would also disable all keyboard avoiding behavior. #416

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/KeyboardAwareHOC.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -392,7 +391,7 @@ function KeyboardAwareHOC(
textInputBottomPosition >
keyboardPosition - totalExtraHeight
) {
this._scrollToFocusedInputWithNodeHandle(
this.props.enableAutomaticScroll && this._scrollToFocusedInputWithNodeHandle(
currentlyFocusedField
)
}
Expand All @@ -406,13 +405,13 @@ function KeyboardAwareHOC(
keyboardSpace =
keyboardSpace -
(textInputBottomPosition - keyboardPosition)
this.setState({ keyboardSpace })
this.scrollForExtraHeightOnAndroid(totalExtraHeight)
// TODO: this wasn't working for castle: this.setState({ keyboardSpace })
this.props.enableAutomaticScroll && this.scrollForExtraHeightOnAndroid(totalExtraHeight)
} else if (
textInputBottomPosition >
keyboardPosition - totalExtraHeight
) {
this.scrollForExtraHeightOnAndroid(
this.props.enableAutomaticScroll && this.scrollForExtraHeightOnAndroid(
totalExtraHeight -
(keyboardPosition - textInputBottomPosition)
)
Expand All @@ -423,7 +422,7 @@ function KeyboardAwareHOC(
}
}
)
}

if (!this.props.resetScrollToCoords) {
if (!this.defaultResetScrollToCoords) {
this.defaultResetScrollToCoords = this.position
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down