mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix keyboardDismissMode="on-drag" on Android (#31943)
Summary: Fixes https://github.com/facebook/react-native/issues/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: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a40f973f58
commit
7edf9274cf
@@ -1178,11 +1178,6 @@ class ScrollView extends React.Component<Props, State> {
|
||||
);
|
||||
}
|
||||
}
|
||||
if (Platform.OS === 'android') {
|
||||
if (this.props.keyboardDismissMode === 'on-drag' && this._isTouching) {
|
||||
dismissKeyboard();
|
||||
}
|
||||
}
|
||||
this._observedScrollSinceBecomingResponder = true;
|
||||
this.props.onScroll && this.props.onScroll(e);
|
||||
};
|
||||
@@ -1299,6 +1294,14 @@ class ScrollView extends React.Component<Props, State> {
|
||||
*/
|
||||
_handleScrollBeginDrag: (e: ScrollEvent) => void = (e: ScrollEvent) => {
|
||||
FrameRateLogger.beginScroll(); // TODO: track all scrolls after implementing onScrollEndAnimation
|
||||
|
||||
if (
|
||||
Platform.OS === 'android' &&
|
||||
this.props.keyboardDismissMode === 'on-drag'
|
||||
) {
|
||||
dismissKeyboard();
|
||||
}
|
||||
|
||||
this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user