Skip to content

[Bug] Wrong pointerEvents behaviour on 0.21.1 #2801

@staszekscp

Description

@staszekscp

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

  1. Add a View with inline style={{ pointerEvents: 'box-none'}}
  2. Open Elements in the Inspector and notice that the style was not applied

Wrong propagation

  1. Add a View with style={{ pointerEvents: 'none'}} (created via StyleSheet.create())
  2. Nest another View with style={{ pointerEvents: 'box-none'}} (created via StyleSheet.create())
  3. Nest one more View with an onPress
  4. The onPress should be triggered, since its parent has box-none value, therefore its children should get pointerEvents: '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-web v0.20.0 reproduction - The event get triggered only when passing pointerEvents via StyleSheet.create()
  • react-native-web v0.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 none value

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions