Skip to content

Make react-juce onMouseEnter and onMouseLeave events behave like their web counterparts #230

@androidStern

Description

@androidStern

The Problem

react-juce mouseEnter and mouseLeave events don't behave like their web counterparts

Background

Juce's mouseEnter and mouseExit events differ from their browser counterparts in a few ways (detailed below). Because react-juce simply forwards Juce mouse events onto the javascript engine, the react environment has inherited Juce's behavior which is unintuitive for react developers. So, the goal here is to make the behavior in react-juce components conform to the web behaviors as much as possible.

Behavior Differences

  1. When moving from a parent to a child element
    • Juce (and by extension, react-juce) will fire a mouseLeave on the Parent and a mouseEnter on the Child
    • Browsers will only fire a mouseEnter on the Child
  2. When moving from a child to it's parent
    • Juce will fire a mouse leave on the Child and a mouseEnter on it's Parent
    • Browsers will only fire a mouseLeave on the child
  3. When entering an exiting elements while holding the mouse button down
    • Juce will not fire any enter or exit events
    • Browsers will fire both events as described above
  4. mouseEnter and mouseLeave events dont bubble in browser but do in current react-juce

TLDR for points 1 & 2: From the browser's perspective, the mouse is still inside an element if it is inside any of its children and mouse buttons have no effect.

Extra Stuff

To get a feel for how these events behave in the browser you can check out this page.

See this discord thread for additional context

Finally, I haven't researched what the expected behavior is when the DOM hierarchy changes while the mouse is moving but that's something to consider as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions