Skip to content

Commit 9caa494

Browse files
committed
small refactor for scroll to focused input + can now also take a isFocused function from ref
1 parent 70d48af commit 9caa494

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"type": "git",
88
"url": "https://github.com/wix/react-native-keyboard-aware-scrollview.git"
99
},
10-
"version": "1.1.6",
10+
"version": "1.1.7",
1111
"description": "React Native Keyboard Aware ScrollView - auto adjust content ScrollView",
1212
"nativePackage": true,
1313
"bugs": {

src/KeyboardAwareBase.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,16 @@ export default class KeyboardAwareBase extends Component {
7878
_scrollToFocusedTextInput() {
7979
if (this.props.getTextInputRefs) {
8080
const textInputRefs = this.props.getTextInputRefs();
81-
textInputRefs.forEach((textInputRef) => {
82-
if (textInputRef && textInputRef.isFocused()) {
81+
textInputRefs.some((textInputRef, index, array) => {
82+
const isFocusedFunc = textInputRef.isFocused();
83+
const isFocused = isFocusedFunc && (typeof isFocusedFunc === "function") ? isFocusedFunc() : isFocusedFunc;
84+
if (isFocused) {
8385
setTimeout(() => {
8486
this._keyboardAwareView.getScrollResponder().scrollResponderScrollNativeHandleToKeyboard(
8587
ReactNative.findNodeHandle(textInputRef), this.props.scrollToInputAdditionalOffset, true);
8688
}, 0);
87-
return;
8889
}
90+
return isFocused;
8991
});
9092
}
9193
}

0 commit comments

Comments
 (0)