-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Make paper ref accessible #35082
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix should be as simple as doing:
diff --git a/packages/mui-material/src/SwipeableDrawer/SwipeableDrawer.js b/packages/mui-material/src/SwipeableDrawer/SwipeableDrawer.js
index 89a02141c8..29eed9dd4c 100644
--- a/packages/mui-material/src/SwipeableDrawer/SwipeableDrawer.js
+++ b/packages/mui-material/src/SwipeableDrawer/SwipeableDrawer.js
@@ -574,7 +574,7 @@ const SwipeableDrawer = React.forwardRef(function SwipeableDrawer(inProps, ref)
pointerEvents: variant === 'temporary' && !open ? 'none' : '',
...PaperProps.style,
},
- ref: paperRef,
+ ref: PaperProps.ref || paperRef,
}}
anchor={anchor}
transitionDuration={calculatedDurationRef.current || transitionDuration}
packages/mui-material/src/SwipeableDrawer/SwipeableDrawer.test.js
Outdated
Show resolved
Hide resolved
Thanks for reviewing @ZeeshanTamboli 🙏, I've updated code as described. |
@sai6855 Actually I think your previous logic was correct: diff --git a/packages/mui-material/src/SwipeableDrawer/SwipeableDrawer.js b/packages/mui-material/src/SwipeableDrawer/SwipeableDrawer.js
index 89a02141c8..c786d47a40 100644
--- a/packages/mui-material/src/SwipeableDrawer/SwipeableDrawer.js
+++ b/packages/mui-material/src/SwipeableDrawer/SwipeableDrawer.js
@@ -166,7 +166,9 @@ const SwipeableDrawer = React.forwardRef(function SwipeableDrawer(inProps, ref)
const swipeAreaRef = React.useRef();
const backdropRef = React.useRef();
- const paperRef = React.useRef();
+ const localPaperRef = React.useRef();
+
+ const paperRef = PaperProps.ref || localPaperRef;
const touchDetected = React.useRef(false); Because I apologize for the mistake. Test looks good. |
This is incorrect |
okay @ZeeshanTamboli no issues, so according to my previous logic as typeof paperRef would be "any", because of this type "any" eslint is suggesting to include paperRef in dependency array. So is it fine if i include paperRef in useEffect in dependency array or do you have any other solution in mind?
|
It's fine to include it in the dependency array if eslint complains about it. But I think actually the |
Signed-off-by: Zeeshan Tamboli <[email protected]>
Signed-off-by: Zeeshan Tamboli <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Signed-off-by: Zeeshan Tamboli <[email protected]> Co-authored-by: Zeeshan Tamboli <[email protected]>
Signed-off-by: Zeeshan Tamboli <[email protected]> Co-authored-by: Zeeshan Tamboli <[email protected]>
Fixes: #35069