-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
different behavior between React and Preact w/ React-MUI #4710
Comments
UPDATE: on further debugging, it looks like there is more. There seems to be an event: 'focusout' which is fired in Preact, and (I suppose) not in React.. uhm.. This event is captured here: and causes the unwanted behavior. So it looks like preact is firing a focusout event through these event listeners ( Perhaps the apparent event mismatch can be due to this? Line 178 in 1effaa6
And then, the mui code has some conditions on the 'blur' event, but since here it gets a 'focusout', the behavior differs. |
First off, mandatory disclaimer that Preact uses native web events whilst React uses a custom event system that diverges to varying degrees. The native The issue here however is that MUI doesn't correctly capture native
Just to clarify, if we didn't alias the event to I'm not sure there's much we can do here, this is a rather big divergence in events/event handling which is generally out of scope for Preact. Using |
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(?)
The text was updated successfully, but these errors were encountered: