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][Paper] Cannot read properties of undefined reading 'paper' #41272

Closed
Abhay5855 opened this issue Feb 26, 2024 · 11 comments
Closed
Assignees
Labels
component: Paper This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material status: waiting for author Issue with insufficient information

Comments

@Abhay5855
Copy link

Abhay5855 commented Feb 26, 2024

Steps to reproduce

Link to live example: https://mui.com/material-ui/customization/palette/

Steps:

  1. Install MUI v5 (5.15.1).
  2. Import ThemeProvider and createTheme from mui/material/styles.
  3. Using the palette from createTheme.
  4. Using the button component
  5. on rendering getting the error cannot read properties of undefined (reading 'paper').
    image

Current behavior

import { css } from "@emotion/react";
import { createTheme, Theme } from "@mui/material/styles";

import { themeV1Vars, themeV2Vars } from "./colors";


export const themeV1: Theme = createTheme({
  palette: {
    primary: {
      main: themeV1Vars.p1,
    },
    secondary: {
      main: themeV1Vars.p2,
    },
    mode: "light",
  },
  typography: {
    fontFamily: `"Inter", Helvetica, Arial, sans-serif`,
    button: {
      textTransform: "capitalize",
    },
  },
});

export const themeV2: Theme = createTheme({
  palette: {
    primary: {
      main: themeV2Vars.p1,
    },
    secondary: {
      main: themeV2Vars.p2,
    },
    mode: "dark",
  },
  typography: {
    fontFamily: `"Inter", Helvetica, Arial, sans-serif`,
    button: {
      textTransform: "capitalize",
    },
  },
});

export const themeV1Colors: { [key: string]: string } = {
  ...themeV1Vars,
  background: themeV1Vars.palette.background.paper,
};

export const themeV2Colors: { [key: string]: string } = {
  ...themeV2Vars,
  background: themeV2Vars.palette.background.paper,
};

Using this code It was working before, but after it is throwing an error, It is working on some browsers but not working on some.

Expected behavior

Originally it was working the palette.backgroud.paper was running and working, but initially it is not working on some browsers, locally I am using MUI version 5.15.1.

Context

For creating themes, I am using the themeProvider from MUI, But due to some reasons It is throwing error on running the app, It works on refresh but again throws the error, I also tried upgrading to v5 (5.15.11), still facing the same issue.

Your environment

No response

Search keywords: paper

Search keywords:

@Abhay5855 Abhay5855 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 26, 2024
@alexfauquette
Copy link
Member

The Paper component in in the material-ui repo. I'm transfering the issue.

Except if it's an already known issue, I doubt the team could do something with you issue without a reproduction. Consider adding a codesandbow, or a stackblitz demo of your bug

@alexfauquette alexfauquette transferred this issue from mui/mui-x Feb 26, 2024
@Abhay5855
Copy link
Author

Abhay5855 commented Feb 26, 2024

image
This is the code I have done and above is the issue produced in the browser.

@sumitappt
Copy link

sumitappt commented Feb 26, 2024

I don't know if it's the same issue but I'm also facing the
same problem i'm getting getContrastText undefined

@Abhay5855
Copy link
Author

unnamed (1)
The palette.background does not have the paper property defined, hence it's throwing error.

@zannager zannager added the component: Paper This is the name of the generic UI component, not the React module! label Feb 26, 2024
@danilo-leal danilo-leal changed the title Cannot read properties of undefined reading 'paper' [material-ui][Paper] Cannot read properties of undefined reading 'paper' Feb 26, 2024
@danilo-leal danilo-leal added the package: material-ui Specific to @mui/material label Feb 26, 2024
@ARJ2160
Copy link
Contributor

ARJ2160 commented Feb 27, 2024

I'm shooting in the dark here but shouldn't Mui provide all the properties and functions like getContrastText and paper itself?
As I see it createTheme is supposed to append custom styles/properties and also default functions from the library.
Any reason why the behavior of createTheme has changed suddenly?

@siriwatknp
Copy link
Member

Can you provide a CodeSandbox that reproduces the issue? It's hard for maintainer to suggest a fix without a reproducible sandbox.

@siriwatknp siriwatknp 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 Feb 27, 2024
@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 Feb 27, 2024
@Abhay5855
Copy link
Author

Can you provide a CodeSandbox that reproduces the issue? It's hard for maintainer to suggest a fix without a reproducible sandbox.

https://codesandbox.io/p/sandbox/back-ns3wv4?file=%2Fsrc%2FApp.js%3A1%2C1-57%2C1

@azabonik
Copy link

azabonik commented Mar 4, 2024

Are there any updates or workarounds for this? Our development team is basically fully-blocked due to this issue.

@siriwatknp
Copy link
Member

Can you provide a CodeSandbox that reproduces the issue? It's hard for maintainer to suggest a fix without a reproducible sandbox.

https://codesandbox.io/p/sandbox/back-ns3wv4?file=%2Fsrc%2FApp.js%3A1%2C1-57%2C1

@Abhay5855 is it not working? I can console.log(theme.palette.background.paper).

@siriwatknp
Copy link
Member

Are there any updates or workarounds for this? Our development team is basically fully-blocked due to this issue.

I still could not reproduce the issue. Can you share a codesandbox?

@siriwatknp siriwatknp 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 Mar 5, 2024
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Paper This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material status: waiting for author Issue with insufficient information
Projects
None yet
Development

No branches or pull requests

8 participants