Skip to content

Commit 98d2382

Browse files
authored
A version with the RN ancestor stuff (APSL#57)
Changed code to match the latest version of the RN pull request
1 parent 7d6b269 commit 98d2382

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/KeyboardAwareMixin.js

Lines changed: 10 additions & 6 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 } from 'react-native'
4+
import ReactNative, { TextInput, Keyboard, UIManager } from 'react-native'
55
import TimerMixin from 'react-timer-mixin'
66

77
const _KAM_DEFAULT_TAB_BAR_HEIGHT = 49
@@ -52,11 +52,15 @@ const KeyboardAwareMixin = {
5252
if (!currentlyFocusedField) {
5353
return
5454
}
55-
try {
56-
this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField)
57-
} catch (e) {
58-
59-
}
55+
UIManager.viewIsDescendantOf(
56+
currentlyFocusedField,
57+
this.getScrollResponder().getInnerViewNode(),
58+
(isAncestor) => {
59+
if (isAncestor) {
60+
this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField)
61+
}
62+
}
63+
)
6064
}
6165
},
6266

0 commit comments

Comments
 (0)