Skip to content

Commit ef77a42

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Stop special-casing Android 11+ from large form-factor keyboardShouldPersistTaps behavior
Summary: ScrollView has special-case logic to dismiss keyboard on tap, controlled via the `keyboardShouldPersistTaps` property. The first click does not propagate to children of the scrollview if the tap causes the keyboard to be dismissed. This behavior is motivated by a soft keyboard on phones which takes away space from the viewport. ScrollView historically determined if a soft-keyboard was open via querying if there was a focused TextInput. This meant that clicks to a ScrollView would be eaten, even on form factors using phsyical keyboards. A couple years ago I added #30374 to only eat clicks when keyboard events have indicated that a soft keyboard is present. I special-cased Android out of the change, because of platform issues with its reliability of keyboard events. After D38500859 (1e48274) rolls out we can start to remove that special-casing, of devices which report "android" for Platform.OS. Reviewed By: javache Differential Revision: D38528887 fbshipit-source-id: a745b478b18abe4ef32cbdd8a14ca6dfdb5e738f
1 parent fd1e82a commit ef77a42

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Libraries/Components/ScrollView/ScrollView.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,10 +1545,9 @@ class ScrollView extends React.Component<Props, State> {
15451545

15461546
// Even if an input is focused, we may not have a keyboard to dismiss. E.g
15471547
// when using a physical keyboard. Ensure we have an event for an opened
1548-
// keyboard, except on Android where setting windowSoftInputMode to
1549-
// adjustNone leads to missing keyboard events.
1548+
// keyboard.
15501549
const softKeyboardMayBeOpen =
1551-
this._keyboardMetrics != null || Platform.OS === 'android';
1550+
this._keyboardMetrics != null || this._keyboardEventsAreUnreliable();
15521551

15531552
return hasFocusedTextInput && softKeyboardMayBeOpen;
15541553
};
@@ -1562,6 +1561,12 @@ class ScrollView extends React.Component<Props, State> {
15621561
return this._keyboardMetrics != null && this._keyboardMetrics.height === 0;
15631562
};
15641563

1564+
_keyboardEventsAreUnreliable: () => boolean = () => {
1565+
// Android versions prior to API 30 rely on observing layout changes when
1566+
// `android:windowSoftInputMode` is set to `adjustResize` or `adjustPan`.
1567+
return Platform.OS === 'android' && Platform.Version < 30;
1568+
};
1569+
15651570
/**
15661571
* Invoke this from an `onTouchEnd` event.
15671572
*

0 commit comments

Comments
 (0)