-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the issue
While working on the bump we've noticed that pointerEvents behaviour has changed causing multiple strange bugs in the app. After an investigation I noticed that in many places the pointerEvents got overridden by other inherited values.
After creating a minimal reproduction I discovered that the pointerEvents worked correctly in the previous version. However they must have been passed to components via StyleSheet.create(). When passed by inline styling or a JavaScript object, box-none nor box-only properties were not applied.
The previous version worked correctly, because even when passing the pointer-event only to the closest children via > * CSS was taking care of everything via inheritance.
Screen.Recording.2025-08-22.at.11.47.10.mov
Expected behavior
Passing the pointerEvents property should behave the same no matter if passed by StyleSheet.create() or inline styling.
What's more I believe that the previous StyleSheet.create() implementation should be brought back, since it worked as I would expect:
<View style={styles.pointerEventsNone}> // none
<View style={styles.pointerEventsBoxNone}> // none
// From here we should have 'auto'
<View>
<View
onClick={() => {
console.log("Should work");
}}
/>
</View>
</View>
</View>
The only thing would be to make sure the same logic as in StyleSheet/compiler/index was applied for any other way of styling.
Steps to reproduce
Inline styling bug
- Add a
Viewwith inlinestyle={{ pointerEvents: 'box-none'}} - Open
Elementsin the Inspector and notice that the style was not applied
Wrong propagation
- Add a
Viewwithstyle={{ pointerEvents: 'none'}}(created viaStyleSheet.create()) - Nest another
Viewwithstyle={{ pointerEvents: 'box-none'}}(created viaStyleSheet.create()) - Nest one more
Viewwith anonPress - The
onPressshould be triggered, since its parent hasbox-nonevalue, therefore its children should getpointerEvents: 'auto'following heuristic that descendants should inherit from the closest ancestor.
Test case
https://codesandbox.io/p/sandbox/condescending-wildflower-z6vzpv
Additional comments
react-native-webv0.20.0 reproduction - The event get triggered only when passingpointerEventsviaStyleSheet.create()react-native-webv0.21.1 reproduction - In both cases the buttons don't work while they should- React example - shows a similar case where the button gets triggered, even though the grandparent has the
nonevalue