-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[SwipeableDrawer] swipe action doesn't work with preact #18977
Comments
@tky5622 Could it be a bug in Preact? Unrelated to Material-UI? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I still don't know the exact cause of it. if synthetic event is used in swipe action, the problem is not with preact. |
As far as I could dive into it, the issue comes from preact not firing the ref, in: Without the reference to the paper DOM element, nothing works. I don't think that we can do more about it here. I would encourage you to report the issue on Preact side. |
@oliviertassinari what's the reason for manually recreating object refs using |
@developit I think that the motivation was to support the case when a developer provides a custom Backdrop that doesn't use In the case of the Paper, it seems to be legacy, we can drop it :). Nice finding! |
@tky5622 Do you want to solve this problem? I think that we could move forward with this simple fix :) diff --git a/packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.js b/packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.js
index ddd7944600..0d59b86719 100644
--- a/packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.js
+++ b/packages/material-ui/src/SwipeableDrawer/SwipeableDrawer.js
@@ -504,11 +504,6 @@ const SwipeableDrawer = React.forwardRef(function SwipeableDrawer(props, ref) {
backdropRef.current = ReactDOM.findDOMNode(instance);
}, []);
- const handlePaperRef = React.useCallback(instance => {
- // #StrictMode ready
- paperRef.current = ReactDOM.findDOMNode(instance);
- }, []);
-
return (
<React.Fragment>
<Drawer
@@ -527,7 +522,7 @@ const SwipeableDrawer = React.forwardRef(function SwipeableDrawer(props, ref) {
pointerEvents: variant === 'temporary' && !open ? 'none' : '',
...PaperProps.style,
},
- ref: handlePaperRef,
+ ref: paperRef,
}}
anchor={anchor}
transitionDuration={calculatedDurationRef.current || transitionDuration} |
I will take give this a go as I am working on this feature lately and nobody has done anything on this yet. Check the PR I created: |
Current Behavior 😯
Swiping to open or close drawer don't work with preact.
only works swipe area's touch event.
In case of using react with same code, drawer works properly.
Expected Behavior 🤔
swipeable drawer can detect touch event and handle state.
Steps:
Context 🔦
Your Environment 🌎
reproduction
sandbox (swipe is not work in sandbox editor)
https://codesandbox.io/s/exciting-worker-i67ug
[for reproduction] please swipe from right in this page
https://i67ug.sse.codesandbox.io/index
The text was updated successfully, but these errors were encountered: