You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an element with the css rule pointer-events: none has a descendant with the rule pointer-events: all, then the descendant's mouse events are bubbled up to all of its ancestors
As far as I understand, there may be a behavioral problem with the pointer-events feature. If the elements are disabled with pointer-events: none, you can solve the mouse events of the child elements with pointer-events: all from being transferred correctly to the parent elements as follows
Solutions:
Use Side-by-Side Level Elements:
Avoid this problem by using elements at the same level rather than nested elements. Thus, the pointer-events property will work without being affected.
Divide Events Further:
Bind events to more specific elements so that each element processes only its own events. This will prevent unwanted domain sharing.
Try an Alternative CSS Approach:
Maybe changing pointer-events dynamically in a particular case or using a different structure could solve the problem.
Preventing React Event Bubbling:
Prevent events from being escalated by catching React events and stopping them. You can catch the onMouseLeave event and stop the event from being propagated upwards using methods such as e.preventDefault() or e.stopPropagation().
Which Approach Should You Use?:
Do trial and error to determine which approach works best for your situation. This will depend on your specific use case and needs.
If an element with the css rule
pointer-events: none
has a descendant with the rulepointer-events: all
, then the descendant's mouse events are bubbled up to all of its ancestorsReact version: 18.2
Steps To Reproduce
onMouseLeave
callback will be firedLink to code example:
https://codesandbox.io/p/sandbox/tender-smoke-cqk24y?file=%2Fsrc%2Findex.js%3A1%2C1-40%2C1
The current behavior
The
onMouseLeave
event is propagated beyond the component which was actually leftThe expected behavior
The
onMouseLeave
trigger is called for the element which was moused away from, and not its parentsThe text was updated successfully, but these errors were encountered: