From 81ec95dfd04ea43e9480cec08bdea630f7a2f51e Mon Sep 17 00:00:00 2001 From: Leo Kapsokalyvas Date: Tue, 13 Mar 2018 10:40:35 +0000 Subject: [PATCH] Ensures that the keyboard accessory view does not obscure other UI elements when keyboard is hidden --- lib/KeyboardAccessoryView.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/KeyboardAccessoryView.js b/lib/KeyboardAccessoryView.js index 299d3ec..966bff3 100644 --- a/lib/KeyboardAccessoryView.js +++ b/lib/KeyboardAccessoryView.js @@ -46,6 +46,7 @@ class KeyboardAccessoryView extends Component { this.state = { keyboardHeight: 0, accessoryHeight: 50, + visibleAccessoryHeight: 50, isKeyboardVisible: false, } @@ -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, }); } @@ -88,6 +90,7 @@ class KeyboardAccessoryView extends Component { this.setState({ isKeyboardVisible: true, keyboardHeight: keyboardEvent.endCoordinates.height, + accessoryHeight: this.state.visibleAccessoryHeight, }) } @@ -103,6 +106,7 @@ class KeyboardAccessoryView extends Component { this.setState({ isKeyboardVisible: false, keyboardHeight: 0, + accessoryHeight: this.props.alwaysVisible ? this.state.visibleAccessoryHeight : 0, }) }