Skip to content
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

[material-ui][Drawer] React does not recognize the slotProps prop #42106

Open
Danielvandervelden opened this issue May 3, 2024 · 2 comments
Open
Assignees
Labels
component: drawer This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@Danielvandervelden
Copy link

Danielvandervelden commented May 3, 2024

Steps to reproduce

Link to live example: (required)

Steps:

  1. Import a Drawer component
  2. Add slotProps={{ backdrop: { onClick: onCloseNav } }} to it
  3. On mobile it works just fine, however on desktop it complains about React not recognising slotProps on element.

Current behavior

When loading the Drawer component on desktop with slotProps passed to it, it complains that React doesn't recognise this prop on a div HTML DOM element.

Expected behavior

It shouldn't complain error out.

Context

I want to close the drawer when the backdrop is clicked, so I need to pass the onClick listener for the backdrop through the slotProps of the Drawer component.

Your environment

npx @mui/envinfo
Chrome

 System:
    OS: macOS 14.3
  Binaries:
    Node: 21.6.2 - ~/.nvm/versions/node/v21.6.2/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v21.6.2/bin/npm
    pnpm: 8.15.4 - ~/.nvm/versions/node/v21.6.2/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.118
    Edge: Not Found
    Safari: 17.3
  npmPackages:
    @emotion/react: ^11.11.4 => 11.11.4 
    @emotion/styled: ^11.11.5 => 11.11.5 
    @mui/base:  5.0.0-beta.40 
    @mui/core-downloads-tracker:  5.15.16 
    @mui/icons-material: ^5.15.16 => 5.15.16 
    @mui/lab: ^5.0.0-alpha.170 => 5.0.0-alpha.170 
    @mui/material: ^5.15.16 => 5.15.16 
    @mui/private-theming:  5.15.14 
    @mui/styled-engine:  5.15.14 
    @mui/system:  5.15.15 
    @mui/types:  7.2.14 
    @mui/utils:  5.15.14 
    @types/react: ^18.3.1 => 18.3.1 
    react: ^18.3.1 => 18.3.1 
    react-dom: ^18.3.1 => 18.3.1 
    typescript: ^5.4.5 => 5.4.5 

Search keywords: slotProps drawer component

@Danielvandervelden Danielvandervelden added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 3, 2024
@zannager zannager added the component: drawer This is the name of the generic UI component, not the React module! label May 3, 2024
@danilo-leal danilo-leal changed the title Passing slotProps to a Drawer component causes React to complain only on desktop "React does not recognize the slotProps prop on a DOM element." [material-ui][Drawer] React does not recognize the slotProps prop May 7, 2024
@danilo-leal danilo-leal added the package: material-ui Specific to @mui/material label May 7, 2024
@danilo-leal
Copy link
Contributor

Hey, thanks for opening the issue! Could you provide a minimal reproduction? It helps us troubleshoot. A live example would be perfect. This StackBlitz sandbox template may be a good starting point.

@danilo-leal danilo-leal added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 7, 2024
@Danielvandervelden
Copy link
Author

Danielvandervelden commented May 8, 2024

Hey @danilo-leal , yes I can create that for you here you go:

https://stackblitz.com/edit/stackblitz-starters-wcks5r?file=src%2FApp.tsx

We switch from permanent to temporary Drawer state when we go from mobile > desktop. If you load the Drawer on desktop you'll see the issue in your console. If you load it on mobile, you don't. I now realise I left out this crucial information, sorry 😅. Seems to be mainly related to the switching between permanent and temporary.

Hopefully this helps!

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: drawer This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants