Skip to content

Commit 026f5da

Browse files
Saadnajmitido64
andauthored
fix(presssability): don't set keyboard event handlers on iOS and Android (#2624)
## Summary: Only set the keyboard event handlers on macOS. This matches what React Native Windows does. While here, update our pod file lock and pbxproj. ## Test Plan: Fixes a bug where <Text> had the keyboard handlers on it set, which red boxed since the handlers don't exist in their native components. --------- Co-authored-by: Tommy Nguyen <[email protected]>
1 parent 20c4bd4 commit 026f5da

File tree

11 files changed

+381
-271
lines changed

11 files changed

+381
-271
lines changed

packages/react-native/Libraries/Components/Pressable/__tests__/__snapshots__/Pressable-test.js.snap

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ exports[`<Pressable /> should render as expected: should deep render when mocked
2828
onBlur={[Function]}
2929
onClick={[Function]}
3030
onFocus={[Function]}
31-
onKeyDown={[Function]}
32-
onKeyUp={[Function]}
3331
onResponderGrant={[Function]}
3432
onResponderMove={[Function]}
3533
onResponderRelease={[Function]}
@@ -69,8 +67,6 @@ exports[`<Pressable /> should render as expected: should deep render when not mo
6967
onBlur={[Function]}
7068
onClick={[Function]}
7169
onFocus={[Function]}
72-
onKeyDown={[Function]}
73-
onKeyUp={[Function]}
7470
onResponderGrant={[Function]}
7571
onResponderMove={[Function]}
7672
onResponderRelease={[Function]}
@@ -110,8 +106,6 @@ exports[`<Pressable disabled={true} /> should be disabled when disabled is true:
110106
onBlur={[Function]}
111107
onClick={[Function]}
112108
onFocus={[Function]}
113-
onKeyDown={[Function]}
114-
onKeyUp={[Function]}
115109
onResponderGrant={[Function]}
116110
onResponderMove={[Function]}
117111
onResponderRelease={[Function]}
@@ -151,8 +145,6 @@ exports[`<Pressable disabled={true} /> should be disabled when disabled is true:
151145
onBlur={[Function]}
152146
onClick={[Function]}
153147
onFocus={[Function]}
154-
onKeyDown={[Function]}
155-
onKeyUp={[Function]}
156148
onResponderGrant={[Function]}
157149
onResponderMove={[Function]}
158150
onResponderRelease={[Function]}
@@ -192,8 +184,6 @@ exports[`<Pressable disabled={true} accessibilityState={{}} /> should be disable
192184
onBlur={[Function]}
193185
onClick={[Function]}
194186
onFocus={[Function]}
195-
onKeyDown={[Function]}
196-
onKeyUp={[Function]}
197187
onResponderGrant={[Function]}
198188
onResponderMove={[Function]}
199189
onResponderRelease={[Function]}
@@ -233,8 +223,6 @@ exports[`<Pressable disabled={true} accessibilityState={{}} /> should be disable
233223
onBlur={[Function]}
234224
onClick={[Function]}
235225
onFocus={[Function]}
236-
onKeyDown={[Function]}
237-
onKeyUp={[Function]}
238226
onResponderGrant={[Function]}
239227
onResponderMove={[Function]}
240228
onResponderRelease={[Function]}
@@ -274,8 +262,6 @@ exports[`<Pressable disabled={true} accessibilityState={{checked: true}} /> shou
274262
onBlur={[Function]}
275263
onClick={[Function]}
276264
onFocus={[Function]}
277-
onKeyDown={[Function]}
278-
onKeyUp={[Function]}
279265
onResponderGrant={[Function]}
280266
onResponderMove={[Function]}
281267
onResponderRelease={[Function]}
@@ -315,8 +301,6 @@ exports[`<Pressable disabled={true} accessibilityState={{checked: true}} /> shou
315301
onBlur={[Function]}
316302
onClick={[Function]}
317303
onFocus={[Function]}
318-
onKeyDown={[Function]}
319-
onKeyUp={[Function]}
320304
onResponderGrant={[Function]}
321305
onResponderMove={[Function]}
322306
onResponderRelease={[Function]}
@@ -356,8 +340,6 @@ exports[`<Pressable disabled={true} accessibilityState={{disabled: false}} /> sh
356340
onBlur={[Function]}
357341
onClick={[Function]}
358342
onFocus={[Function]}
359-
onKeyDown={[Function]}
360-
onKeyUp={[Function]}
361343
onResponderGrant={[Function]}
362344
onResponderMove={[Function]}
363345
onResponderRelease={[Function]}
@@ -397,8 +379,6 @@ exports[`<Pressable disabled={true} accessibilityState={{disabled: false}} /> sh
397379
onBlur={[Function]}
398380
onClick={[Function]}
399381
onFocus={[Function]}
400-
onKeyDown={[Function]}
401-
onKeyUp={[Function]}
402382
onResponderGrant={[Function]}
403383
onResponderMove={[Function]}
404384
onResponderRelease={[Function]}

packages/react-native/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableHighlight-test.js.snap

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ exports[`TouchableHighlight renders correctly 1`] = `
1515
enableFocusRing={true}
1616
focusable={false}
1717
onClick={[Function]}
18-
onKeyDown={[Function]}
19-
onKeyUp={[Function]}
2018
onResponderGrant={[Function]}
2119
onResponderMove={[Function]}
2220
onResponderRelease={[Function]}
@@ -51,8 +49,6 @@ exports[`TouchableHighlight with disabled state should be disabled when disabled
5149
enableFocusRing={false}
5250
focusable={false}
5351
onClick={[Function]}
54-
onKeyDown={[Function]}
55-
onKeyUp={[Function]}
5652
onResponderGrant={[Function]}
5753
onResponderMove={[Function]}
5854
onResponderRelease={[Function]}
@@ -84,8 +80,6 @@ exports[`TouchableHighlight with disabled state should be disabled when disabled
8480
enableFocusRing={false}
8581
focusable={false}
8682
onClick={[Function]}
87-
onKeyDown={[Function]}
88-
onKeyUp={[Function]}
8983
onResponderGrant={[Function]}
9084
onResponderMove={[Function]}
9185
onResponderRelease={[Function]}
@@ -117,8 +111,6 @@ exports[`TouchableHighlight with disabled state should disable button when acces
117111
enableFocusRing={true}
118112
focusable={false}
119113
onClick={[Function]}
120-
onKeyDown={[Function]}
121-
onKeyUp={[Function]}
122114
onResponderGrant={[Function]}
123115
onResponderMove={[Function]}
124116
onResponderRelease={[Function]}
@@ -151,8 +143,6 @@ exports[`TouchableHighlight with disabled state should keep accessibilityState w
151143
enableFocusRing={false}
152144
focusable={false}
153145
onClick={[Function]}
154-
onKeyDown={[Function]}
155-
onKeyUp={[Function]}
156146
onResponderGrant={[Function]}
157147
onResponderMove={[Function]}
158148
onResponderRelease={[Function]}
@@ -184,8 +174,6 @@ exports[`TouchableHighlight with disabled state should overwrite accessibilitySt
184174
enableFocusRing={false}
185175
focusable={false}
186176
onClick={[Function]}
187-
onKeyDown={[Function]}
188-
onKeyUp={[Function]}
189177
onResponderGrant={[Function]}
190178
onResponderMove={[Function]}
191179
onResponderRelease={[Function]}

packages/react-native/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableNativeFeedback-test.js.snap

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ exports[`<TouchableNativeFeedback /> should render as expected 1`] = `
2222
accessible={true}
2323
focusable={false}
2424
onClick={[Function]}
25-
onKeyDown={[Function]}
26-
onKeyUp={[Function]}
2725
onResponderGrant={[Function]}
2826
onResponderMove={[Function]}
2927
onResponderRelease={[Function]}
@@ -55,8 +53,6 @@ exports[`<TouchableNativeFeedback disabled={false} accessibilityState={{disabled
5553
accessible={true}
5654
focusable={false}
5755
onClick={[Function]}
58-
onKeyDown={[Function]}
59-
onKeyUp={[Function]}
6056
onResponderGrant={[Function]}
6157
onResponderMove={[Function]}
6258
onResponderRelease={[Function]}
@@ -88,8 +84,6 @@ exports[`<TouchableNativeFeedback disabled={true} accessibilityState={{}}> shoul
8884
accessible={true}
8985
focusable={false}
9086
onClick={[Function]}
91-
onKeyDown={[Function]}
92-
onKeyUp={[Function]}
9387
onResponderGrant={[Function]}
9488
onResponderMove={[Function]}
9589
onResponderRelease={[Function]}
@@ -121,8 +115,6 @@ exports[`<TouchableNativeFeedback disabled={true} accessibilityState={{checked:
121115
accessible={true}
122116
focusable={false}
123117
onClick={[Function]}
124-
onKeyDown={[Function]}
125-
onKeyUp={[Function]}
126118
onResponderGrant={[Function]}
127119
onResponderMove={[Function]}
128120
onResponderRelease={[Function]}
@@ -154,8 +146,6 @@ exports[`<TouchableNativeFeedback disabled={true} accessibilityState={{disabled:
154146
accessible={true}
155147
focusable={false}
156148
onClick={[Function]}
157-
onKeyDown={[Function]}
158-
onKeyUp={[Function]}
159149
onResponderGrant={[Function]}
160150
onResponderMove={[Function]}
161151
onResponderRelease={[Function]}
@@ -187,8 +177,6 @@ exports[`<TouchableNativeFeedback disabled={true}> should be disabled when disab
187177
accessible={true}
188178
focusable={false}
189179
onClick={[Function]}
190-
onKeyDown={[Function]}
191-
onKeyUp={[Function]}
192180
onResponderGrant={[Function]}
193181
onResponderMove={[Function]}
194182
onResponderRelease={[Function]}
@@ -220,8 +208,6 @@ exports[`TouchableWithoutFeedback renders correctly 1`] = `
220208
accessible={true}
221209
focusable={false}
222210
onClick={[Function]}
223-
onKeyDown={[Function]}
224-
onKeyUp={[Function]}
225211
onResponderGrant={[Function]}
226212
onResponderMove={[Function]}
227213
onResponderRelease={[Function]}

packages/react-native/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableOpacity-test.js.snap

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ exports[`TouchableOpacity renders correctly 1`] = `
2525
enableFocusRing={true}
2626
focusable={false}
2727
onClick={[Function]}
28-
onKeyDown={[Function]}
29-
onKeyUp={[Function]}
3028
onResponderGrant={[Function]}
3129
onResponderMove={[Function]}
3230
onResponderRelease={[Function]}
@@ -70,8 +68,6 @@ exports[`TouchableOpacity renders in disabled state when a disabled prop is pass
7068
enableFocusRing={false}
7169
focusable={false}
7270
onClick={[Function]}
73-
onKeyDown={[Function]}
74-
onKeyUp={[Function]}
7571
onResponderGrant={[Function]}
7672
onResponderMove={[Function]}
7773
onResponderRelease={[Function]}
@@ -115,8 +111,6 @@ exports[`TouchableOpacity renders in disabled state when a key disabled in acces
115111
enableFocusRing={true}
116112
focusable={false}
117113
onClick={[Function]}
118-
onKeyDown={[Function]}
119-
onKeyUp={[Function]}
120114
onResponderGrant={[Function]}
121115
onResponderMove={[Function]}
122116
onResponderRelease={[Function]}

packages/react-native/Libraries/Components/Touchable/__tests__/__snapshots__/TouchableWithoutFeedback-test.js.snap

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ exports[`TouchableWithoutFeedback renders correctly 1`] = `
1616
enableFocusRing={false}
1717
focusable={false}
1818
onClick={[Function]}
19-
onKeyDown={[Function]}
20-
onKeyUp={[Function]}
2119
onResponderGrant={[Function]}
2220
onResponderMove={[Function]}
2321
onResponderRelease={[Function]}
@@ -45,8 +43,6 @@ exports[`TouchableWithoutFeedback with disabled state should be disabled when di
4543
enableFocusRing={false}
4644
focusable={false}
4745
onClick={[Function]}
48-
onKeyDown={[Function]}
49-
onKeyUp={[Function]}
5046
onResponderGrant={[Function]}
5147
onResponderMove={[Function]}
5248
onResponderRelease={[Function]}
@@ -72,8 +68,6 @@ exports[`TouchableWithoutFeedback with disabled state should be disabled when di
7268
enableFocusRing={false}
7369
focusable={false}
7470
onClick={[Function]}
75-
onKeyDown={[Function]}
76-
onKeyUp={[Function]}
7771
onResponderGrant={[Function]}
7872
onResponderMove={[Function]}
7973
onResponderRelease={[Function]}
@@ -99,8 +93,6 @@ exports[`TouchableWithoutFeedback with disabled state should disable button when
9993
enableFocusRing={false}
10094
focusable={false}
10195
onClick={[Function]}
102-
onKeyDown={[Function]}
103-
onKeyUp={[Function]}
10496
onResponderGrant={[Function]}
10597
onResponderMove={[Function]}
10698
onResponderRelease={[Function]}
@@ -126,8 +118,6 @@ exports[`TouchableWithoutFeedback with disabled state should keep accessibilityS
126118
enableFocusRing={false}
127119
focusable={false}
128120
onClick={[Function]}
129-
onKeyDown={[Function]}
130-
onKeyUp={[Function]}
131121
onResponderGrant={[Function]}
132122
onResponderMove={[Function]}
133123
onResponderRelease={[Function]}
@@ -153,8 +143,6 @@ exports[`TouchableWithoutFeedback with disabled state should overwrite accessibi
153143
enableFocusRing={false}
154144
focusable={false}
155145
onClick={[Function]}
156-
onKeyDown={[Function]}
157-
onKeyUp={[Function]}
158146
onResponderGrant={[Function]}
159147
onResponderMove={[Function]}
160148
onResponderRelease={[Function]}

packages/react-native/Libraries/Components/__tests__/__snapshots__/Button-test.js.snap

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ exports[`<Button /> should be disabled and it should set accessibilityState to d
2626
enableFocusRing={false}
2727
focusable={false}
2828
onClick={[Function]}
29-
onKeyDown={[Function]}
30-
onKeyUp={[Function]}
3129
onResponderGrant={[Function]}
3230
onResponderMove={[Function]}
3331
onResponderRelease={[Function]}
@@ -96,8 +94,6 @@ exports[`<Button /> should be disabled when disabled is empty and accessibilityS
9694
enableFocusRing={false}
9795
focusable={false}
9896
onClick={[Function]}
99-
onKeyDown={[Function]}
100-
onKeyUp={[Function]}
10197
onResponderGrant={[Function]}
10298
onResponderMove={[Function]}
10399
onResponderRelease={[Function]}
@@ -166,8 +162,6 @@ exports[`<Button /> should be disabled when disabled={true} and accessibilitySta
166162
enableFocusRing={false}
167163
focusable={false}
168164
onClick={[Function]}
169-
onKeyDown={[Function]}
170-
onKeyUp={[Function]}
171165
onResponderGrant={[Function]}
172166
onResponderMove={[Function]}
173167
onResponderRelease={[Function]}
@@ -237,8 +231,6 @@ exports[`<Button /> should be set importantForAccessibility={no-hide-descendants
237231
focusable={false}
238232
importantForAccessibility="no-hide-descendants"
239233
onClick={[Function]}
240-
onKeyDown={[Function]}
241-
onKeyUp={[Function]}
242234
onResponderGrant={[Function]}
243235
onResponderMove={[Function]}
244236
onResponderRelease={[Function]}
@@ -303,8 +295,6 @@ exports[`<Button /> should be set importantForAccessibility={no-hide-descendants
303295
focusable={false}
304296
importantForAccessibility="no-hide-descendants"
305297
onClick={[Function]}
306-
onKeyDown={[Function]}
307-
onKeyUp={[Function]}
308298
onResponderGrant={[Function]}
309299
onResponderMove={[Function]}
310300
onResponderRelease={[Function]}
@@ -368,8 +358,6 @@ exports[`<Button /> should not be disabled when disabled={false} and accessibili
368358
enableFocusRing={true}
369359
focusable={false}
370360
onClick={[Function]}
371-
onKeyDown={[Function]}
372-
onKeyUp={[Function]}
373361
onResponderGrant={[Function]}
374362
onResponderMove={[Function]}
375363
onResponderRelease={[Function]}
@@ -434,8 +422,6 @@ exports[`<Button /> should not be disabled when disabled={false} and accessibili
434422
enableFocusRing={true}
435423
focusable={false}
436424
onClick={[Function]}
437-
onKeyDown={[Function]}
438-
onKeyUp={[Function]}
439425
onResponderGrant={[Function]}
440426
onResponderMove={[Function]}
441427
onResponderRelease={[Function]}
@@ -500,8 +486,6 @@ exports[`<Button /> should overwrite accessibilityState with value of disabled p
500486
enableFocusRing={false}
501487
focusable={false}
502488
onClick={[Function]}
503-
onKeyDown={[Function]}
504-
onKeyUp={[Function]}
505489
onResponderGrant={[Function]}
506490
onResponderMove={[Function]}
507491
onResponderRelease={[Function]}
@@ -570,8 +554,6 @@ exports[`<Button /> should render as expected 1`] = `
570554
enableFocusRing={true}
571555
focusable={false}
572556
onClick={[Function]}
573-
onKeyDown={[Function]}
574-
onKeyUp={[Function]}
575557
onResponderGrant={[Function]}
576558
onResponderMove={[Function]}
577559
onResponderRelease={[Function]}

packages/react-native/Libraries/LogBox/UI/__tests__/__snapshots__/LogBoxInspectorStackFrames-test.js.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ exports[`LogBoxInspectorStackFrames should render stack frames with 1 frame coll
153153
enableFocusRing={true}
154154
focusable={true}
155155
onClick={[Function]}
156-
onKeyDown={[Function]}
157-
onKeyUp={[Function]}
158156
onResponderGrant={[Function]}
159157
onResponderMove={[Function]}
160158
onResponderRelease={[Function]}

0 commit comments

Comments
 (0)