Skip to content

Commit 7edf927

Browse files
janicduplessisfacebook-github-bot
authored andcommitted
Fix keyboardDismissMode="on-drag" on Android (#31943)
Summary: Fixes #23364 The current logic using `_isTouching` does not work because `_handleTouchCancel` is always called before scroll events begin. This means `_isTouching` is always false. To fix it I moved the logic to `_handleScrollBeginDrag` which is only called once when scroll drag beings. This accomplishes the expected behavior and is better than keeping it in onScroll where it would be called for each scroll event. ## Changelog [Android] [Fixed] - Fix keyboardDismissMode="on-drag" on Android Pull Request resolved: #31943 Test Plan: Tested in an app that on-drag does not work before and works after this patch. Reviewed By: sshic Differential Revision: D30674276 Pulled By: yungsters fbshipit-source-id: aa0bd605809fa01518f70fbf323c06e32c76ed1d
1 parent a40f973 commit 7edf927

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Libraries/Components/ScrollView/ScrollView.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -1178,11 +1178,6 @@ class ScrollView extends React.Component<Props, State> {
11781178
);
11791179
}
11801180
}
1181-
if (Platform.OS === 'android') {
1182-
if (this.props.keyboardDismissMode === 'on-drag' && this._isTouching) {
1183-
dismissKeyboard();
1184-
}
1185-
}
11861181
this._observedScrollSinceBecomingResponder = true;
11871182
this.props.onScroll && this.props.onScroll(e);
11881183
};
@@ -1299,6 +1294,14 @@ class ScrollView extends React.Component<Props, State> {
12991294
*/
13001295
_handleScrollBeginDrag: (e: ScrollEvent) => void = (e: ScrollEvent) => {
13011296
FrameRateLogger.beginScroll(); // TODO: track all scrolls after implementing onScrollEndAnimation
1297+
1298+
if (
1299+
Platform.OS === 'android' &&
1300+
this.props.keyboardDismissMode === 'on-drag'
1301+
) {
1302+
dismissKeyboard();
1303+
}
1304+
13021305
this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
13031306
};
13041307

0 commit comments

Comments
 (0)