Skip to content

Commit 5bf3e38

Browse files
zoontekmeta-codesync[bot]
authored andcommitted
Drop boolean support for ScrollView keyboardShouldPersistTaps (#57386)
Summary: Removes support for the deprecated boolean values of `ScrollView`'s `keyboardShouldPersistTaps` prop. `true`/`false` have long been deprecated in favor of the string values `'always'`/`'never'` (with `'handled'` as a third option), and a runtime warning was already emitted when a boolean was passed. This drops the boolean from the type and removes the now-unused boolean handling. Migration: - `keyboardShouldPersistTaps={true}` → `keyboardShouldPersistTaps="always"` - `keyboardShouldPersistTaps={false}` → `keyboardShouldPersistTaps="never"` See #57384 ## Changelog: [GENERAL] [BREAKING] - Remove deprecated boolean values support for `ScrollView` `keyboardShouldPersistTaps` Pull Request resolved: #57386 Test Plan: - `yarn flow` passes (the previously-needed `$FlowFixMe[sketchy-null-bool]` suppressions are gone). - `yarn build-types` regenerates `ReactNativeApi.d.ts` with `keyboardShouldPersistTaps?: "always" | "handled" | "never"`. - RNTester ScrollView "Keyboard" example still toggles between `never`/`always`/`handled`. Reviewed By: cortinico, rozele Differential Revision: D110218873 Pulled By: Abbondanzo fbshipit-source-id: 2cb86fe8b058432795cddc3f4f2c2cb1b1fd1fdf
1 parent 0fae86d commit 5bf3e38

4 files changed

Lines changed: 17 additions & 50 deletions

File tree

packages/react-native/Libraries/Components/ScrollView/ScrollView.d.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -671,15 +671,8 @@ export interface ScrollViewProps
671671
* - 'never' (the default), tapping outside of the focused text input when the keyboard is up dismisses the keyboard. When this happens, children won't receive the tap.
672672
* - 'always', the keyboard will not dismiss automatically, and the scroll view will not catch taps, but children of the scroll view can catch taps.
673673
* - 'handled', the keyboard will not dismiss automatically when the tap was handled by a children, (or captured by an ancestor).
674-
* - false, deprecated, use 'never' instead
675-
* - true, deprecated, use 'always' instead
676674
*/
677-
keyboardShouldPersistTaps?:
678-
| boolean
679-
| 'always'
680-
| 'never'
681-
| 'handled'
682-
| undefined;
675+
keyboardShouldPersistTaps?: 'always' | 'never' | 'handled' | undefined;
683676

684677
/**
685678
* Called when scrollable content view of the ScrollView changes.

packages/react-native/Libraries/Components/ScrollView/ScrollView.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,10 @@ type ScrollViewBaseProps = Readonly<{
581581
* catch taps, but children of the scroll view can catch taps.
582582
* - `'handled'`, the keyboard will not dismiss automatically when the tap was handled by
583583
* children, (or captured by an ancestor).
584-
* - `false`, deprecated, use `'never'` instead.
585-
* - `true`, deprecated, use `'always'` instead.
586584
*
587585
* @default `'never'`
588586
*/
589-
keyboardShouldPersistTaps?: ?('always' | 'never' | 'handled' | true | false),
587+
keyboardShouldPersistTaps?: ?('always' | 'never' | 'handled'),
590588
/**
591589
* When set, the scroll view will adjust the scroll position so that the first child that is
592590
* partially or fully visible and at or beyond `minIndexForVisible` will not change position.
@@ -888,17 +886,6 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
888886
};
889887

890888
componentDidMount() {
891-
if (typeof this.props.keyboardShouldPersistTaps === 'boolean') {
892-
console.warn(
893-
`'keyboardShouldPersistTaps={${
894-
this.props.keyboardShouldPersistTaps === true ? 'true' : 'false'
895-
}}' is deprecated. ` +
896-
`Use 'keyboardShouldPersistTaps="${
897-
this.props.keyboardShouldPersistTaps ? 'always' : 'never'
898-
}"' instead`,
899-
);
900-
}
901-
902889
this._keyboardMetrics = Keyboard.metrics();
903890
this._additionalScrollOffset = 0;
904891

@@ -1483,7 +1470,6 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
14831470
const currentlyFocusedTextInput = TextInputState.currentlyFocusedInput();
14841471
if (
14851472
currentlyFocusedTextInput != null &&
1486-
this.props.keyboardShouldPersistTaps !== true &&
14871473
this.props.keyboardShouldPersistTaps !== 'always' &&
14881474
this._keyboardIsDismissible() &&
14891475
e.target !== currentlyFocusedTextInput &&

packages/react-native/Libraries/Lists/FlatList.d.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,8 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
2929
* - 'never' (the default), tapping outside of the focused text input when the keyboard is up dismisses the keyboard. When this happens, children won't receive the tap.
3030
* - 'always', the keyboard will not dismiss automatically, and the scroll view will not catch taps, but children of the scroll view can catch taps.
3131
* - 'handled', the keyboard will not dismiss automatically when the tap was handled by a children, (or captured by an ancestor).
32-
* - false, deprecated, use 'never' instead
33-
* - true, deprecated, use 'always' instead
34-
*/
35-
keyboardShouldPersistTaps?:
36-
| boolean
37-
| 'always'
38-
| 'never'
39-
| 'handled'
40-
| undefined;
32+
*/
33+
keyboardShouldPersistTaps?: 'always' | 'never' | 'handled' | undefined;
4134

4235
/**
4336
* An array (or array-like list) of items to render. Other data types can be

packages/react-native/ReactNativeApi.d.ts

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<10889ead2857238c3286b036b73f9945>>
7+
* @generated SignedSource<<cd9e044d46b56e7d426d264274dc8533>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -4369,12 +4369,7 @@ declare type ScrollViewBaseProps = {
43694369
readonly innerViewRef?: React.Ref<InnerViewInstance>
43704370
readonly invertStickyHeaders?: boolean
43714371
readonly keyboardDismissMode?: "interactive" | "none" | "on-drag"
4372-
readonly keyboardShouldPersistTaps?:
4373-
| "always"
4374-
| "handled"
4375-
| "never"
4376-
| false
4377-
| true
4372+
readonly keyboardShouldPersistTaps?: "always" | "handled" | "never"
43784373
readonly maintainVisibleContentPosition?: {
43794374
readonly autoscrollToTopThreshold?: number
43804375
readonly minIndexForVisible: number
@@ -5926,7 +5921,7 @@ export {
59265921
AlertOptions, // a0cdac0f
59275922
AlertType, // 5ab91217
59285923
AndroidKeyboardEvent, // e03becc8
5929-
Animated, // 8d5b3c35
5924+
Animated, // 91a7b171
59305925
AppConfig, // 35c0ca70
59315926
AppRegistry, // 7ef8e53a
59325927
AppState, // 12012be5
@@ -5976,9 +5971,9 @@ export {
59765971
EventSubscription, // b8d084aa
59775972
ExtendedExceptionData, // 5a6ccf5a
59785973
FilterFunction, // bf24c0e3
5979-
FlatList, // b5cfde24
5980-
FlatListInstance, // 8f76f3b2
5981-
FlatListProps, // 3725656d
5974+
FlatList, // 0f2531c9
5975+
FlatListInstance, // f31d4744
5976+
FlatListProps, // b8b5adf2
59825977
FocusEvent, // 850f1517
59835978
FontVariant, // 7c7558bb
59845979
GestureResponderEvent, // 14d3e77a
@@ -6118,18 +6113,18 @@ export {
61186113
ScrollEvent, // d7abdd0a
61196114
ScrollResponderType, // 079145bb
61206115
ScrollToLocationParamsType, // d7ecdad1
6121-
ScrollView, // 9c14c51c
6116+
ScrollView, // d7defbe2
61226117
ScrollViewImperativeMethods, // d3ff1532
61236118
ScrollViewInstance, // 1ba64600
6124-
ScrollViewProps, // c92ac7be
6119+
ScrollViewProps, // 9207390b
61256120
ScrollViewPropsAndroid, // 44210553
61266121
ScrollViewPropsIOS, // da991b9a
61276122
ScrollViewScrollToOptions, // 3313411e
61286123
SectionBase, // dca83594
6129-
SectionList, // 626263b4
6124+
SectionList, // f483c886
61306125
SectionListData, // e0d79987
6131-
SectionListInstance, // 019cdaef
6132-
SectionListProps, // 4cb9dfa9
6126+
SectionListInstance, // 1b255509
6127+
SectionListProps, // e06b9868
61336128
SectionListRenderItem, // 466e3e87
61346129
SectionListRenderItemInfo, // d809238e
61356130
Separators, // 6a45f7e3
@@ -6203,10 +6198,10 @@ export {
62036198
VirtualViewMode, // 6be59722
62046199
VirtualizedList, // 68c7345e
62056200
VirtualizedListInstance, // 423ee7c0
6206-
VirtualizedListProps, // 29367911
6201+
VirtualizedListProps, // cc8bc4c9
62076202
VirtualizedSectionList, // 9fd9cd61
62086203
VirtualizedSectionListInstance, // 12b706d5
6209-
VirtualizedSectionListProps, // 6b9d9c05
6204+
VirtualizedSectionListProps, // 12a58a4f
62106205
WrapperComponentProvider, // 4b8c7962
62116206
codegenNativeCommands, // 628a7c0a
62126207
codegenNativeComponent, // 32a1bca6

0 commit comments

Comments
 (0)