mui / mui/material-ui

Drawer issues with lazy loaded components

Open
#36,934 10 comments 6 reactions 1 assignee View on GitHub

@mnajdova is already working on this.

Since Apr 20, 2023.

scope: drawer
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Duplicates
  • I have searched the existing issues
Latest version
  • I have tested the latest version
Steps to reproduce 🕹

Link to live example: https://codesandbox.io/s/mui-drawer-with-lazy-components-yyg5n0

Steps:

  1. click the button in the page to open the drawer
  2. click a link in drawer to change route
  3. sometimes the drawer won't close anymore
Current behavior 😯

Sometimes the Drawer seems to ignore the open prop and stays opened even if set to false.

Expected behavior 🤔

The Drawer should close if the open prop equals true

Context 🔦

We use the drawer as a sidebar navigation, each children is a react router <Link> pointing to a dedicated <Route> which will render a React.lazy loaded component.

The issues is not present using standard component imports.

Your environment 🌎
npx @mui/envinfo
  System:
    OS: macOS 13.3
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.15.0/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
  Browsers:
    Chrome: 112.0.5615.121
    Edge: Not Found
    Firefox: 107.0
    Safari: 16.4

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.