Skip to content

different behavior between React and Preact w/ React-MUI #4710

Open
@krskrs

Description

@krskrs
  • Check if updating to the latest Preact version resolves the issue
    No

Describe the bug
I stumbled upon a different behavior between React and Preact w/ React-MUI

To Reproduce

I've found out that the React-MUI SpeedDial component works differently on React and Preact, making its usage on Preact very problematic.

First thing, the difference seems to exist on mobile only (touch behavior?) (must be tested with the desktop browser in mobile emulation)

It looks like Preact is handling/sending some events differently because, after opening the speeddial and clicking on the RED button, on Preact, an onMouseLeave event seems to be fired on the SpeedDial component, making it invoke its internal onClose callback (please see the console and the code). On react, on the contrary, the click on the button is correctly caught by the button, which will fire its onClick handler and the onMouseLeave event won't be fired.

SpeedDial Component
https://mui.com/material-ui/react-speed-dial/

SpeedDial Component Internal related references:

https://github.com/mui/material-ui/blob/6f2b908baa7863e2cbf0ec4518dc90ccfd53597b/packages/mui-material/src/SpeedDial/SpeedDial.js#L277
https://github.com/mui/material-ui/blob/6f2b908baa7863e2cbf0ec4518dc90ccfd53597b/packages/mui-material/src/SpeedDial/SpeedDial.js#L410
https://github.com/mui/material-ui/blob/6f2b908baa7863e2cbf0ec4518dc90ccfd53597b/packages/mui-material/src/SpeedDial/SpeedDial.js#L413

React reproduction:
https://codesandbox.io/p/devbox/wonderful-kate-xjt857?workspaceId=ws_LCddBC1t6QqksLkm3bx3c

Preact reproduction:
https://codesandbox.io/p/sandbox/66xhq9

As a side note, I also tested this with preact 10.0.0, where the debounce logic had changed. The behavior slightly changed, although it still wasn't identical to react. However, after I investigated further, this doesn't seem to be much relevant to the actual issue itself.

Expected behavior
What should have happened when following the steps above?

work like React, the Speeddial shouldn't close when clicking the red button, and the onMouseLeave event shouldn't be emitted(?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions