mui / mui/material-ui

[swipeable drawer] External ref causes mergeSlotProps to overwrite internal ref

Open
#48,009 3 comments 0 reactions 1 assignee View on GitHub

@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:

  1. Open this live example: https://stackblitz.com/edit/ob1sd6fc-ta22ng51?file=src%2FDemo.tsx
  2. Open the preview in a touch-enabled device or enable touch emulation in DevTools
  3. Click either "Open Test 1" or "Open Test 2" button to open either drawer
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.