Skip to content

Commit 75974af

Browse files
author
Kebab
authored
Set default of viewIsInsideTabBar to true. Remember lastKeyboardSpace and use this as the default
-Fixes keyboard space being missing when keyboard is open and you move to another View that requires a keyboard space
1 parent 53ceaef commit 75974af

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/KeyboardAwareMixin.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @flow */
22

33
import { PropTypes } from 'react'
4-
import ReactNative, { TextInput, Keyboard, UIManager } from 'react-native'
4+
import ReactNative, { TextInput, Keyboard, UIManager, Platform } from 'react-native'
55
import TimerMixin from 'react-timer-mixin'
66

77
import type { Event } from 'react-native'
@@ -10,6 +10,8 @@ const _KAM_DEFAULT_TAB_BAR_HEIGHT: number = 49
1010
const _KAM_KEYBOARD_OPENING_TIME: number = 250
1111
const _KAM_EXTRA_HEIGHT: number = 75
1212

13+
var lastKeyboardSpace = 0;
14+
1315
const KeyboardAwareMixin = {
1416
mixins: [TimerMixin],
1517
propTypes: {
@@ -25,12 +27,13 @@ const KeyboardAwareMixin = {
2527
extraHeight: _KAM_EXTRA_HEIGHT,
2628
extraScrollHeight: 0,
2729
enableResetScrollToCoords: true,
30+
viewIsInsideTabBar: true
2831
}
2932
},
3033

3134
setViewIsInsideTabBar: function (viewIsInsideTabBar: bool) {
3235
this.viewIsInsideTabBar = viewIsInsideTabBar
33-
const keyboardSpace = viewIsInsideTabBar ? _KAM_DEFAULT_TAB_BAR_HEIGHT : 0
36+
const keyboardSpace = lastKeyboardSpace; //viewIsInsideTabBar ? _KAM_DEFAULT_TAB_BAR_HEIGHT : 0
3437
if (this.state.keyboardSpace !== keyboardSpace) {
3538
this.setState({keyboardSpace})
3639
}
@@ -55,6 +58,7 @@ const KeyboardAwareMixin = {
5558
if (this.props.viewIsInsideTabBar) {
5659
keyboardSpace -= _KAM_DEFAULT_TAB_BAR_HEIGHT
5760
}
61+
lastKeyboardSpace = keyboardSpace;
5862
this.setState({keyboardSpace})
5963
// Automatically scroll to focused TextInput
6064
if (this.props.enableAutoAutomaticScroll) {
@@ -86,6 +90,7 @@ const KeyboardAwareMixin = {
8690

8791
resetKeyboardSpace: function () {
8892
const keyboardSpace: number = (this.props.viewIsInsideTabBar) ? _KAM_DEFAULT_TAB_BAR_HEIGHT + this.props.extraScrollHeight : this.props.extraScrollHeight
93+
lastKeyboardSpace = keyboardSpace;
8994
this.setState({keyboardSpace})
9095
// Reset scroll position after keyboard dismissal
9196
if (this.props.enableResetScrollToCoords === false) {

0 commit comments

Comments
 (0)