Skip to content

Commit

Permalink
Ensures that the keyboard accessory view does not obscure other UI el…
Browse files Browse the repository at this point in the history
…ements when keyboard is hidden
  • Loading branch information
Leo Kapsokalyvas committed Mar 13, 2018
1 parent 9b02f55 commit 81ec95d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/KeyboardAccessoryView.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class KeyboardAccessoryView extends Component {
this.state = {
keyboardHeight: 0,
accessoryHeight: 50,
visibleAccessoryHeight: 50,
isKeyboardVisible: false,
}

Expand All @@ -68,7 +69,8 @@ class KeyboardAccessoryView extends Component {

handleChildrenLayout(layoutEvent) {
this.setState({
accessoryHeight: layoutEvent.nativeEvent.layout.height,
visibleAccessoryHeight: layoutEvent.nativeEvent.layout.height,
accessoryHeight: this.props.alwaysVisible ? layoutEvent.nativeEvent.layout.height : 0,
});
}

Expand All @@ -88,6 +90,7 @@ class KeyboardAccessoryView extends Component {
this.setState({
isKeyboardVisible: true,
keyboardHeight: keyboardEvent.endCoordinates.height,
accessoryHeight: this.state.visibleAccessoryHeight,
})
}

Expand All @@ -103,6 +106,7 @@ class KeyboardAccessoryView extends Component {
this.setState({
isKeyboardVisible: false,
keyboardHeight: 0,
accessoryHeight: this.props.alwaysVisible ? this.state.visibleAccessoryHeight : 0,
})
}

Expand Down

0 comments on commit 81ec95d

Please sign in to comment.