Skip to content

Commit 153dc08

Browse files
janicduplessisalvaromb
authored andcommitted
Only scroll to input when hidden by the keyboard (APSL#67)
1 parent ef46a11 commit 153dc08

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/KeyboardAwareMixin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,18 @@ const KeyboardAwareMixin = {
5252
if (!currentlyFocusedField) {
5353
return
5454
}
55+
5556
UIManager.viewIsDescendantOf(
5657
currentlyFocusedField,
5758
this.getScrollResponder().getInnerViewNode(),
5859
(isAncestor) => {
5960
if (isAncestor) {
60-
this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField)
61+
// Check if the TextInput will be hidden by the keyboard
62+
UIManager.measureInWindow(currentlyFocusedField, (x, y, width, height) => {
63+
if (y + height > frames.endCoordinates.screenY) {
64+
this.scrollToFocusedInputWithNodeHandle(currentlyFocusedField)
65+
}
66+
})
6167
}
6268
}
6369
)

0 commit comments

Comments
 (0)