Skip to content
Open
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
8 changes: 6 additions & 2 deletions Libraries/Components/Keyboard/KeyboardAvoidingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const KeyboardAvoidingView = React.createClass({

subscriptions: ([]: Array<EmitterSubscription>),
frame: (null: ?Rect),
firstFrame: (null: ?Rect),

relativeKeyboardHeight(keyboardFrame: ScreenRect): number {
const frame = this.frame;
Expand Down Expand Up @@ -122,6 +123,9 @@ const KeyboardAvoidingView = React.createClass({
},

onLayout(event: LayoutEvent) {
if(!this.firstFrame){
this.firstFrame = event.nativeEvent.layout;
}
this.frame = event.nativeEvent.layout;
},

Expand Down Expand Up @@ -158,12 +162,12 @@ const KeyboardAvoidingView = React.createClass({
switch (behavior) {
case 'height':
let heightStyle;
if (this.frame) {
if (this.firstFrame) {
// Note that we only apply a height change when there is keyboard present,
// i.e. this.state.bottom is greater than 0. If we remove that condition,
// this.frame.height will never go back to its original value.
// When height changes, we need to disable flex.
heightStyle = {height: this.frame.height - this.state.bottom, flex: 0};
heightStyle = {height: this.firstFrame.height - this.state.bottom, flex: 0};
}
return (
<View ref={viewRef} style={[style, heightStyle]} onLayout={this.onLayout} {...props}>
Expand Down