Skip to content

Commit ee6edd3

Browse files
authored
Update when topSpacing prop is changed
Andr3wHur5t#56 A fix for Andr3wHur5t#49. I tried to avoid manually writing a componentWillReceiveProps function to keep the code simpler.
1 parent cfe6e03 commit ee6edd3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

KeyboardSpacer.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export default class KeyboardSpacer extends Component {
105105
// when external physical keyboard is connected
106106
// event.endCoordinates.height still equals virtual keyboard height
107107
// however only the keyboard toolbar is showing if there should be one
108-
const keyboardSpace = (screenHeight - event.endCoordinates.screenY) + this.props.topSpacing;
108+
const keyboardSpace = screenHeight - event.endCoordinates.screenY;
109109
this.setState({
110110
keyboardSpace,
111111
isKeyboardOpened: true
@@ -135,6 +135,17 @@ export default class KeyboardSpacer extends Component {
135135

136136
render() {
137137
return (
138-
<View style={[styles.container, { height: this.state.keyboardSpace }, this.props.style]} />);
138+
<View
139+
style={[
140+
styles.container,
141+
{
142+
height:
143+
this.state.keyboardSpace +
144+
(this.state.isKeyboardOpened ? this.props.topSpacing : 0)
145+
},
146+
this.props.style
147+
]}
148+
/>
149+
);
139150
}
140151
}

0 commit comments

Comments
 (0)