ReactUnity / core

React and HTML framework for Unity UI & UIToolkit
https://reactunity.github.io/
MIT License
723 stars 38 forks source link

[UGUI] Pointer events are not consistent if parent have none and children have auto #79

Closed Muchaszewski closed 1 year ago

Muchaszewski commented 1 year ago

Issue

Consider the following code

    <div style={{backgroundColor: 'yellow', opacity: '0.5', pointerEvents: "none"}}>
      <button style={{pointerEvents: "auto"}} onClick={() => console.log("i was clicked")}>Click me</button>
    </div >

Current outcome

The button is not responsive

Expected outcome

The button can be clicked, and the div is unclickable and does not block the UI/Gameplay Ray casting. So if something is below it's still clickable

Additional info

So there should be the following cases when considering the following hierarchy.

  1. RootCanvas
  2. ReactUI Canvas 2a) Div 2b) Button

where pe = pointerEvents

Note

When div does not have a background color and pointer events, it works as intended, where you can interact with the button and the elements below ReactUICanvas

    <div>
      <button onClick={() => console.log("i was clicked")}>Click me</button>
    </div >
KurtGokhan commented 1 year ago

Not sure if this can be implemented, but will check. This may help when implementing.

KurtGokhan commented 1 year ago

CSS isolation: isolate now sets ignoreParentGroups to true. This could be automated but it is hard to do and may affect performance. Also this resets opacity and it becomes very hard to calculate opacity like browsers. So users should explicitly set isolation: isolate if they want this behavior.

KurtGokhan commented 1 year ago

Added in the v0.14.0