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][AppBar] color="inherit" is inconsistent between ThemeProvider and experimental_CssVarsProvider #42379

Closed
jacobwahoo opened this issue May 24, 2024 · 3 comments · Fixed by #42714
Assignees
Labels
bug 🐛 Something doesn't work component: app bar This is the name of the generic UI component, not the React module! customization: theme Centered around the theming features package: material-ui Specific to @mui/material regression A bug, but worse

Comments

@jacobwahoo
Copy link

jacobwahoo commented May 24, 2024

Steps to reproduce

Link to live example: Code Sandbox

Steps:

  1. Create an App that uses experimental_CssVarsProvider with experimental_extendTheme
  2. Set a background color on an element
  3. Inside the element with the background color, add an AppBar component with color set to "inherit"

In the above code sandbox, it's got the exact same setup for both pairs of AppBars, but the top one uses ThemeProvider and createTheme, while the bottom one uses experimental_CssVarsProvider and experimental_extendTheme, but the ones that use "inherit" are different colors.
Screenshot 2024-05-24 at 10 10 33 AM

Current behavior

The AppBar's background color is the color if the element underneath it. (which is what the "transparent" color is meant to do)

Expected behavior

The AppBar's background color should be the default Paper color.

Context

We just want the AppBar to be the default Paper background color 😄

Your environment

npx @mui/envinfo

System:
OS: macOS 14.5
Binaries:
Node: 18.7.0 - ~/.nvm/versions/node/v18.7.0/bin/node
npm: 8.19.4 - ~/Git/settings-mfe/node_modules/.bin/npm
pnpm: Not Found
Browsers:
Chrome: 125.0.6422.112
Edge: Not Found
Safari: 17.5
npmPackages:
@emotion/react: ^11.11.3 => 11.11.3
@emotion/styled: ^11.11.0 => 11.11.0
@mui/base: 5.0.0-beta.36
@mui/core-downloads-tracker: 5.15.9
@mui/icons-material: ^5.15.13 => 5.15.13
@mui/material: ^5.15.4 => 5.15.9
@mui/private-theming: 5.15.9
@mui/styled-engine: 5.15.9
@mui/system: ^5.15.4 => 5.15.9
@mui/types: 7.2.13
@mui/utils: 5.15.9
@mui/x-date-pickers: ^6.19.0 => 6.19.4
@types/react: ^18.2.43 => 18.2.55
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
typescript: ^5.2.2 => 5.3.3

I used both Chrome and Firefox

Search keywords: inherit AppBar experimental_CssVarsProvider experimental_extendTheme

@jacobwahoo jacobwahoo added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 24, 2024
@zannager zannager added package: system Specific to @mui/system customization: theme Centered around the theming features labels May 27, 2024
@danilo-leal danilo-leal changed the title color="inherit"` is inconsistent between ThemeProvider and experimental_CssVarsProvider [material-ui] color="inherit" is inconsistent between ThemeProvider and experimental_CssVarsProvider May 28, 2024
@danilo-leal danilo-leal added the package: material-ui Specific to @mui/material label May 28, 2024
@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Jun 12, 2024

It's a bug.

In version 6, the behavior is different (see example), but still incorrect. Both inherit and transparent behave the same.

Is it confirmed that when the App Bar has the color inherit, it should use the default background color of Paper (i.e., white) like with ThemeProvider, since the App Bar component inherits from the Paper component? cc @siriwatknp

@ZeeshanTamboli ZeeshanTamboli added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 12, 2024
@ZeeshanTamboli ZeeshanTamboli changed the title [material-ui] color="inherit" is inconsistent between ThemeProvider and experimental_CssVarsProvider [material-ui][AppBar] color="inherit" is inconsistent between ThemeProvider and experimental_CssVarsProvider Jun 12, 2024
@ZeeshanTamboli ZeeshanTamboli added component: app bar This is the name of the generic UI component, not the React module! and removed package: system Specific to @mui/system labels Jun 12, 2024
@jacobwahoo
Copy link
Author

@ZeeshanTamboli the discussion on this PR seems to indicate that inherit was already being used to get the Paper color, so they added transparent as an option to get the color of the parent component.
#19393

@ZeeshanTamboli
Copy link
Member

It's a regression from #32835. I have created two separate PRs to fix it for v5 and v6 since the code is different for both.

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: app bar This is the name of the generic UI component, not the React module! customization: theme Centered around the theming features package: material-ui Specific to @mui/material regression A bug, but worse
Projects
None yet
5 participants