[swipeable drawer] External ref causes mergeSlotProps to overwrite internal ref
Open
@silviuaavram is already working on this.
Since Mar 23, 2026.
component: SwipeableDrawer
has workaround
type: bug
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Steps to reproduce
Steps:
- Open this live example: https://stackblitz.com/edit/ob1sd6fc-ta22ng51?file=src%2FDemo.tsx
- Open the preview in a touch-enabled device or enable touch emulation in DevTools
- Click either "Open Test 1" or "Open Test 2" button to open either drawer
- Attempt to close the drawer by swiping (touch drag gesture)
Current behavior
The application crashes with the following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'contains')
Expected behavior
The drawer closes
Context
From testing, this happens because mergeSlotProps does not correctly handle the callback ref returned by useForkRef, and will overwrite it with the external ref if present.
Your environment
npx @mui/envinfo
System:
OS: Windows 11 10.0.26100
Binaries:
Node: 20.19.5 - C:\nvm4w\nodejs\node.EXE
npm: 10.8.2 - C:\nvm4w\nodejs\npm.CMD
pnpm: Not Found
Browsers:
Chrome: 135.0.7049.42
npmPackages:
@emotion/react: ^11.14.0 => 11.14.0
@emotion/styled: ^11.14.1 => 11.14.1
@mui/core-downloads-tracker: 7.3.9
@mui/lab: 7.0.1-beta.22 => 7.0.1-beta.22
@mui/material: ^7.3.9 => 7.3.9
@mui/private-theming: 7.3.9
@mui/styled-engine: 7.3.9
@mui/system: 7.3.9
@mui/types: 7.4.12
@mui/utils: 7.3.9
@mui/x-date-pickers: ^7.29.4 => 7.29.4
@mui/x-internals: 7.29.0
@types/react: ^19.2.14 => 19.2.14
react: ^19.2.4 => 19.2.4
react-dom: ^19.2.4 => 19.2.4
typescript: ^5.9.3 => 5.9.3
Search keywords: mergeSlotProps SwipeableDrawer paper ref
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.