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

[DataGrid] styleOverrides does not support Theme typings #5816

Closed
2 tasks done
iigrik opened this issue Aug 17, 2022 · 4 comments · Fixed by #5818
Closed
2 tasks done

[DataGrid] styleOverrides does not support Theme typings #5816

iigrik opened this issue Aug 17, 2022 · 4 comments · Fixed by #5818
Labels
component: data grid This is the name of the generic UI component, not the React module! typescript

Comments

@iigrik
Copy link
Contributor

iigrik commented Aug 17, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Usage of theme object in callback of styleOverrides causing ts error: Object is of type 'unknown'. Issue exist in DataGrid and DataGridPro components.

const theme = createTheme({
  components: {
    MuiDataGrid: {
      styleOverrides: {
        root: ({ theme }) => ({
          backgroundColor: theme.palette.primary.main
        })
      }
    }
  }
});

Expected behavior 🤔

There are no ts errors presented. theme object has correct typing.

Steps to reproduce 🕹

Link to live example: https://codesandbox.io/s/datagridpro-styleoverrides-issue-0k8c4r

Context 🔦

No response

Your environment 🌎

No response

Order ID 💳 (optional)

No response

@iigrik iigrik added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Aug 17, 2022
@iigrik iigrik changed the title [DataGridPro] styleOverrides does not support Theme typings [DataGrid] styleOverrides does not support Theme typings Aug 17, 2022
@minyan-gu
Copy link

noticed same issue, would be nice to have a patch release soon.

@oliviertassinari oliviertassinari added the component: data grid This is the name of the generic UI component, not the React module! label Aug 17, 2022
@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 17, 2022

It makes sense, how the theme should be extended has changed after mui/material-ui#30524 e.g. https://mui.com/material-ui/about-the-lab/#typescript

export interface LabComponents {
  MuiLoadingButton?: {
    defaultProps?: ComponentsProps['MuiLoadingButton'];
    styleOverrides?: ComponentsOverrides<Theme>['MuiLoadingButton'];
    variants?: ComponentsVariants['MuiLoadingButton'];
  };

https://github.com/mui/material-ui/blob/f981c6c2dfd4babfd881fc69912fd8c513d33f2c/packages/mui-lab/src/themeAugmentation/components.d.ts#L16

@iigrik
Copy link
Contributor Author

iigrik commented Aug 17, 2022

@oliviertassinari Should I change/add something to the linked PRs? Is implementation correct?

@iigrik
Copy link
Contributor Author

iigrik commented Aug 17, 2022

@oliviertassinari This issue is also presented in "DatePickerPro" component. Can I create PR in scope of current issue or separate issue should be created?

@m4theushw m4theushw added typescript and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! typescript
Projects
None yet
4 participants