Skip to content

Commit 9b69c73

Browse files
jennifer-dickinsonnecolas
authored andcommitted
[fix] Make children pressable when parent is disabled
It fixes the inconsistency between native builds and react-native-web, where when disabling Pressables and other tappable elements, the children on native builds are still interactable (swiping, tapping, etc) but un-interactable in react-native-web. On react-native-web, the pointerEvents were set to 'none' to address 094bd0e, which causes this inconsistency. The solution was to change from 'none' to 'box-none', which maintains the desired behavior of the original issue and addresses the current. Close #2536 Fix #2391
1 parent 2a901e5 commit 9b69c73

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

packages/react-native-web/src/exports/Pressable/__tests__/__snapshots__/index-test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ exports[`components/Pressable prop "accessibilityRole" value is set 1`] = `
153153
exports[`components/Pressable prop "disabled" 1`] = `
154154
<div
155155
aria-disabled="true"
156-
class="css-view-175oi2r r-pointerEvents-633pao"
156+
class="css-view-175oi2r r-pointerEvents-12vffkv"
157157
tabindex="-1"
158158
/>
159159
`;

packages/react-native-web/src/exports/Pressable/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ const styles = StyleSheet.create({
229229
touchAction: 'manipulation'
230230
},
231231
disabled: {
232-
pointerEvents: 'none'
232+
pointerEvents: 'box-none'
233233
}
234234
});
235235

packages/react-native-web/src/exports/TouchableHighlight/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function TouchableHighlight(props: Props, forwardedRef): React.Node {
175175
{...pressEventHandlers}
176176
accessibilityDisabled={disabled}
177177
focusable={!disabled && focusable !== false}
178-
pointerEvents={disabled ? 'none' : undefined}
178+
pointerEvents={disabled ? 'box-none' : undefined}
179179
ref={setRef}
180180
style={[
181181
styles.root,

packages/react-native-web/src/exports/TouchableOpacity/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function TouchableOpacity(props: Props, forwardedRef): React.Node {
132132
{...pressEventHandlers}
133133
accessibilityDisabled={disabled}
134134
focusable={!disabled && focusable !== false}
135-
pointerEvents={disabled ? 'none' : undefined}
135+
pointerEvents={disabled ? 'box-none' : undefined}
136136
ref={setRef}
137137
style={[
138138
styles.root,

0 commit comments

Comments
 (0)