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

[Dialog] Types are not derived properly for the paper slot when using component #45142

Closed
Jazzmanpw opened this issue Jan 29, 2025 · 2 comments
Closed
Assignees
Labels
component: dialog This is the name of the generic UI component, not the React module! status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it status: waiting for author Issue with insufficient information

Comments

@Jazzmanpw
Copy link

Jazzmanpw commented Jan 29, 2025

Steps to reproduce

Steps:

  1. Open this link to live example
  2. See the two versions of <Dialog /> using different way to customize PaperProps.component

Current behavior

Deprecated DialogProps.PaperProps derives types properly, but DialogProps.slotProps.paper doesn't

Expected behavior

DialogProps.slotProps.paper handles the PaperProps.component prop and allows adding properties that don't exist on a Paper, but exist on the component provided

Context

I'm building a form dialog. I try to follow the example given in the docs for this pattern, but the example uses deprecated API, and the suggested newer API breaks types

Your environment

npx @mui/envinfo

  System:
    OS: Windows 11 10.0.26100
  Binaries:
    Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.6.0 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Chromium (127.0.2651.86)
  npmPackages:
    @emotion/react: ^11.14.0 => 11.14.0 
    @emotion/styled: ^11.14.0 => 11.14.0 
    @mui/core-downloads-tracker:  6.4.1
    @mui/icons-material: ^6.4.1 => 6.4.1
    @mui/material: ^6.4.1 => 6.4.1
    @mui/material-nextjs: ^6.3.1 => 6.3.1
    @mui/private-theming:  6.4.1
    @mui/styled-engine:  6.4.0
    @mui/system:  6.4.1
    @mui/types:  7.2.21
    @mui/utils:  6.4.1
    @types/react: ^19 => 19.0.7
    react: ^19.0.0 => 19.0.0
    react-dom: ^19.0.0 => 19.0.0
    typescript: ^5 => 5.7.

Search keywords: slot, paper, dialog, types

@Jazzmanpw Jazzmanpw added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 29, 2025
@DiegoAndai DiegoAndai self-assigned this Jan 29, 2025
@DiegoAndai DiegoAndai added component: dialog This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 29, 2025
@DiegoAndai DiegoAndai changed the title Types are not derived properly for the paper slot of the Dialog component [Dialog] Types are not derived properly for the paper slot when using component Jan 29, 2025
@DiegoAndai
Copy link
Member

Hey @Jazzmanpw, thanks for reaching out!

To specify other props that are not included, you should use module augmentation. In your example, it would be:

import Dialog from "@mui/material/Dialog";
import { useState } from "react";
import "./styles.css";

declare module "@mui/material/Dialog" {
  interface DialogPaperSlotPropsOverrides {
    noValidate: boolean;
  }
}

// ...

Here's a sandbox: https://codesandbox.io/p/sandbox/issue-45142-solution-t2cwkt

You could also extend it so it includes all of the form's props. Let me know if this works for you.

Copy link

github-actions bot commented Feb 6, 2025

Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information.

@github-actions github-actions bot closed this as completed Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: dialog This is the name of the generic UI component, not the React module! status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it status: waiting for author Issue with insufficient information
Projects
None yet
Development

No branches or pull requests

2 participants