Skip to content

Commit cd84fa4

Browse files
committed
chore: remove automatic cursor pointer (#161)
1 parent b7b544e commit cd84fa4

File tree

7 files changed

+7
-160
lines changed

7 files changed

+7
-160
lines changed

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import type {ViewProps} from '../View/ViewPropTypes';
1818
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
1919
import usePressability from '../../Pressability/usePressability';
2020
import {type RectOrSize} from '../../StyleSheet/Rect';
21-
import StyleSheet from '../../StyleSheet/StyleSheet';
2221
import useMergeRefs from '../../Utilities/useMergeRefs';
2322
import View from '../View/View';
2423
import useAndroidRippleForView, {
@@ -303,23 +302,14 @@ function Pressable(
303302
{...restPropsWithDefaults}
304303
{...eventHandlers}
305304
ref={mergedRef}
306-
style={[
307-
styles.pressable,
308-
typeof style === 'function' ? style({pressed}) : style,
309-
]}
305+
style={typeof style === 'function' ? style({pressed}) : style}
310306
collapsable={false}>
311307
{typeof children === 'function' ? children({pressed}) : children}
312308
{__DEV__ ? <PressabilityDebugView color="red" hitSlop={hitSlop} /> : null}
313309
</View>
314310
);
315311
}
316312

317-
const styles = StyleSheet.create({
318-
pressable: {
319-
cursor: 'pointer',
320-
},
321-
});
322-
323313
function usePressState(forcePressed: boolean): [boolean, (boolean) => void] {
324314
const [pressed, setPressed] = useState(false);
325315
return [pressed || forcePressed, setPressed];

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

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@ exports[`<Pressable /> should render as expected: should deep render when mocked
3131
onResponderTerminate={[Function]}
3232
onResponderTerminationRequest={[Function]}
3333
onStartShouldSetResponder={[Function]}
34-
style={
35-
Array [
36-
Object {
37-
"cursor": "pointer",
38-
},
39-
undefined,
40-
]
41-
}
4234
>
4335
<View />
4436
</View>
@@ -75,14 +67,6 @@ exports[`<Pressable /> should render as expected: should deep render when not mo
7567
onResponderTerminate={[Function]}
7668
onResponderTerminationRequest={[Function]}
7769
onStartShouldSetResponder={[Function]}
78-
style={
79-
Array [
80-
Object {
81-
"cursor": "pointer",
82-
},
83-
undefined,
84-
]
85-
}
8670
>
8771
<View />
8872
</View>
@@ -119,14 +103,6 @@ exports[`<Pressable disabled={true} /> should be disabled when disabled is true:
119103
onResponderTerminate={[Function]}
120104
onResponderTerminationRequest={[Function]}
121105
onStartShouldSetResponder={[Function]}
122-
style={
123-
Array [
124-
Object {
125-
"cursor": "pointer",
126-
},
127-
undefined,
128-
]
129-
}
130106
>
131107
<View />
132108
</View>
@@ -163,14 +139,6 @@ exports[`<Pressable disabled={true} /> should be disabled when disabled is true:
163139
onResponderTerminate={[Function]}
164140
onResponderTerminationRequest={[Function]}
165141
onStartShouldSetResponder={[Function]}
166-
style={
167-
Array [
168-
Object {
169-
"cursor": "pointer",
170-
},
171-
undefined,
172-
]
173-
}
174142
>
175143
<View />
176144
</View>
@@ -207,14 +175,6 @@ exports[`<Pressable disabled={true} accessibilityState={{}} /> should be disable
207175
onResponderTerminate={[Function]}
208176
onResponderTerminationRequest={[Function]}
209177
onStartShouldSetResponder={[Function]}
210-
style={
211-
Array [
212-
Object {
213-
"cursor": "pointer",
214-
},
215-
undefined,
216-
]
217-
}
218178
>
219179
<View />
220180
</View>
@@ -251,14 +211,6 @@ exports[`<Pressable disabled={true} accessibilityState={{}} /> should be disable
251211
onResponderTerminate={[Function]}
252212
onResponderTerminationRequest={[Function]}
253213
onStartShouldSetResponder={[Function]}
254-
style={
255-
Array [
256-
Object {
257-
"cursor": "pointer",
258-
},
259-
undefined,
260-
]
261-
}
262214
>
263215
<View />
264216
</View>
@@ -295,14 +247,6 @@ exports[`<Pressable disabled={true} accessibilityState={{checked: true}} /> shou
295247
onResponderTerminate={[Function]}
296248
onResponderTerminationRequest={[Function]}
297249
onStartShouldSetResponder={[Function]}
298-
style={
299-
Array [
300-
Object {
301-
"cursor": "pointer",
302-
},
303-
undefined,
304-
]
305-
}
306250
>
307251
<View />
308252
</View>
@@ -339,14 +283,6 @@ exports[`<Pressable disabled={true} accessibilityState={{checked: true}} /> shou
339283
onResponderTerminate={[Function]}
340284
onResponderTerminationRequest={[Function]}
341285
onStartShouldSetResponder={[Function]}
342-
style={
343-
Array [
344-
Object {
345-
"cursor": "pointer",
346-
},
347-
undefined,
348-
]
349-
}
350286
>
351287
<View />
352288
</View>
@@ -383,14 +319,6 @@ exports[`<Pressable disabled={true} accessibilityState={{disabled: false}} /> sh
383319
onResponderTerminate={[Function]}
384320
onResponderTerminationRequest={[Function]}
385321
onStartShouldSetResponder={[Function]}
386-
style={
387-
Array [
388-
Object {
389-
"cursor": "pointer",
390-
},
391-
undefined,
392-
]
393-
}
394322
>
395323
<View />
396324
</View>
@@ -427,14 +355,6 @@ exports[`<Pressable disabled={true} accessibilityState={{disabled: false}} /> sh
427355
onResponderTerminate={[Function]}
428356
onResponderTerminationRequest={[Function]}
429357
onStartShouldSetResponder={[Function]}
430-
style={
431-
Array [
432-
Object {
433-
"cursor": "pointer",
434-
},
435-
undefined,
436-
]
437-
}
438358
>
439359
<View />
440360
</View>

packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,10 @@ class TouchableHighlightImpl extends React.Component<
350350
accessibilityElementsHidden={
351351
this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden
352352
}
353-
style={[
354-
styles.touchable,
355-
StyleSheet.compose(
356-
this.props.style,
357-
this.state.extraStyles?.underlay,
358-
),
359-
]}
353+
style={StyleSheet.compose(
354+
this.props.style,
355+
this.state.extraStyles?.underlay,
356+
)}
360357
onLayout={this.props.onLayout}
361358
hitSlop={this.props.hitSlop}
362359
hasTVPreferredFocus={this.props.hasTVPreferredFocus}

packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import Pressability, {
1818
} from '../../Pressability/Pressability';
1919
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
2020
import flattenStyle from '../../StyleSheet/flattenStyle';
21-
import StyleSheet from '../../StyleSheet/StyleSheet';
2221
import Platform from '../../Utilities/Platform';
2322
import * as React from 'react';
2423

@@ -318,7 +317,7 @@ class TouchableOpacity extends React.Component<TouchableOpacityProps, State> {
318317
accessibilityElementsHidden={
319318
this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden
320319
}
321-
style={[styles.touchable, this.props.style, {opacity: this.state.anim}]}
320+
style={[this.props.style, {opacity: this.state.anim}]}
322321
nativeID={this.props.id ?? this.props.nativeID}
323322
testID={this.props.testID}
324323
onLayout={this.props.onLayout}

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

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ exports[`TouchableHighlight renders correctly 1`] = `
1919
onResponderTerminate={[Function]}
2020
onResponderTerminationRequest={[Function]}
2121
onStartShouldSetResponder={[Function]}
22-
style={
23-
Array [
24-
Object {
25-
"cursor": "pointer",
26-
},
27-
Object {},
28-
]
29-
}
22+
style={Object {}}
3023
>
3124
<Text>
3225
Touchable
@@ -58,14 +51,6 @@ exports[`TouchableHighlight with disabled state should be disabled when disabled
5851
onResponderTerminate={[Function]}
5952
onResponderTerminationRequest={[Function]}
6053
onStartShouldSetResponder={[Function]}
61-
style={
62-
Array [
63-
Object {
64-
"cursor": "pointer",
65-
},
66-
undefined,
67-
]
68-
}
6954
>
7055
<View />
7156
</View>
@@ -95,14 +80,6 @@ exports[`TouchableHighlight with disabled state should be disabled when disabled
9580
onResponderTerminate={[Function]}
9681
onResponderTerminationRequest={[Function]}
9782
onStartShouldSetResponder={[Function]}
98-
style={
99-
Array [
100-
Object {
101-
"cursor": "pointer",
102-
},
103-
undefined,
104-
]
105-
}
10683
>
10784
<View />
10885
</View>
@@ -132,14 +109,6 @@ exports[`TouchableHighlight with disabled state should disable button when acces
132109
onResponderTerminate={[Function]}
133110
onResponderTerminationRequest={[Function]}
134111
onStartShouldSetResponder={[Function]}
135-
style={
136-
Array [
137-
Object {
138-
"cursor": "pointer",
139-
},
140-
undefined,
141-
]
142-
}
143112
>
144113
<View />
145114
</View>
@@ -170,14 +139,6 @@ exports[`TouchableHighlight with disabled state should keep accessibilityState w
170139
onResponderTerminate={[Function]}
171140
onResponderTerminationRequest={[Function]}
172141
onStartShouldSetResponder={[Function]}
173-
style={
174-
Array [
175-
Object {
176-
"cursor": "pointer",
177-
},
178-
undefined,
179-
]
180-
}
181142
>
182143
<View />
183144
</View>
@@ -207,14 +168,6 @@ exports[`TouchableHighlight with disabled state should overwrite accessibilitySt
207168
onResponderTerminate={[Function]}
208169
onResponderTerminationRequest={[Function]}
209170
onStartShouldSetResponder={[Function]}
210-
style={
211-
Array [
212-
Object {
213-
"cursor": "pointer",
214-
},
215-
undefined,
216-
]
217-
}
218171
>
219172
<View />
220173
</View>

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ exports[`TouchableOpacity renders correctly 1`] = `
3131
onStartShouldSetResponder={[Function]}
3232
style={
3333
Object {
34-
"cursor": "pointer",
3534
"opacity": 1,
3635
}
3736
}
@@ -73,7 +72,6 @@ exports[`TouchableOpacity renders in disabled state when a disabled prop is pass
7372
onStartShouldSetResponder={[Function]}
7473
style={
7574
Object {
76-
"cursor": "pointer",
7775
"opacity": 1,
7876
}
7977
}
@@ -115,7 +113,6 @@ exports[`TouchableOpacity renders in disabled state when a key disabled in acces
115113
onStartShouldSetResponder={[Function]}
116114
style={
117115
Object {
118-
"cursor": "pointer",
119116
"opacity": 1,
120117
}
121118
}

0 commit comments

Comments
 (0)