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

Overriding MuiTableCell using variants gives "Failed prop type" warning #33793

Closed
2 tasks done
arjunvkurup opened this issue Aug 4, 2022 · 2 comments · Fixed by #33856
Closed
2 tasks done

Overriding MuiTableCell using variants gives "Failed prop type" warning #33793

arjunvkurup opened this issue Aug 4, 2022 · 2 comments · Fixed by #33856
Labels
bug 🐛 Something doesn't work component: table This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. typescript

Comments

@arjunvkurup
Copy link
Contributor

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Gettings a warning as provided below

Warning: Failed prop type: Invalid prop variantof valuetableHeadingsupplied toForwardRef(TableCell), expected one of ["body","footer","head"].

Expected behavior 🤔

Should be able to override the default variants with custom TableCell variants

Steps to reproduce 🕹

Steps:

  1. Override MuiTableCell using the styleOverrides property
  2. use the snippet provide below
MuiTableCell: {
    styleOverrides: {
      root: {
        border: "none",
        backgroundColor: "#142243",
      }
    },
    variants: [
      {
        props: { variant: "tableHeading" },
        style: {
          fontSize: "1.375em",
          fontFamily: "Whyte",
          color: "#C1D3FF",
        }
      },
    ]
  },

Context 🔦

Instead of the default variants props provide in TableCell component, I want to override and add multiple variants with custom properties.

Your environment 🌎

npx @mui/envinfo
Used Brave browser for testing purpose.
System:
    OS: macOS 12.5
  Binaries:
    Node: 16.15.1 - /usr/local/bin/node
    Yarn: Not Found
    npm: 8.11.0 - /usr/local/bin/npm
  Browsers:
    Chrome: Not Found
    Edge: Not Found
    Firefox: Not Found
    Brave: 1.41.100 (Chromium: 103.0.5060.134)
    Safari: 15.6
  npmPackages:
    @emotion/react: ^11.8.1 => 11.8.1 
    @emotion/styled: ^11.8.1 => 11.8.1 
    @mui/base:  5.0.0-alpha.70 
    @mui/icons-material: ^5.4.4 => 5.4.4 
    @mui/material: ^5.4.4 => 5.4.4 
    @mui/private-theming:  5.4.4 
    @mui/styled-engine:  5.4.4 
    @mui/styles: ^5.5.0 => 5.5.0 
    @mui/system:  5.4.4 
    @mui/types:  7.1.2 
    @mui/utils:  5.7.0 
    @mui/x-date-pickers: ^5.0.0-alpha.2 => 5.0.0-alpha.2 
    @types/react:  16.14.26 
    react: 17.0.2 => 17.0.2 
    react-dom: 17.0.2 => 17.0.2 
    typescript:  4.7.3 
@arjunvkurup arjunvkurup added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 4, 2022
@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Aug 8, 2022

Not only a warning is thrown but also there is a TypeScript error for overriding via module augmentation. Fix can be applied similar to #33816. Only that #33816 was for size prop, this is for variant prop. Would you like to create a PR for it?

@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work good first issue Great for first contributions. Enable to learn the contribution process. component: table This is the name of the generic UI component, not the React module! typescript and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 8, 2022
@arjunvkurup
Copy link
Contributor Author

Yes, I will create a PR for this issue

arjunvkurup added a commit to arjunvkurup/material-ui that referenced this issue Aug 8, 2022
arjunvkurup added a commit to arjunvkurup/material-ui that referenced this issue Aug 8, 2022
ZeeshanTamboli pushed a commit that referenced this issue Aug 9, 2022
…on (#33856)

* [TableCell] Enable variant overrides (#33793)

* added prettier (#33793)

* fix redundant module declaration
daniel-rabe pushed a commit to daniel-rabe/material-ui that referenced this issue Nov 29, 2022
…on (mui#33856)

* [TableCell] Enable variant overrides (mui#33793)

* added prettier (mui#33793)

* fix redundant module declaration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: table This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants