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

[AppBar][material-ui] Type error for color property with "error", "warning" and "success" values #39053

Closed
2 tasks done
BreakBB opened this issue Sep 19, 2023 · 6 comments · Fixed by #39389
Closed
2 tasks done
Labels
bug 🐛 Something doesn't work component: app bar 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. package: material-ui Specific to @mui/material typescript

Comments

@BreakBB
Copy link
Contributor

BreakBB commented Sep 19, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example: https://codesandbox.io/s/inspiring-edison-3ffqdm?file=/src/App.tsx

In the example above Typescript complains about the color attribute having a value different to:

'default' | 'inherit' | 'primary' | 'secondary' | 'transparent'

Even though the AppBar color docs also list | string as possible value for the color property.

Current behavior 😯

The application is colored as expected, but Typescript complains about it.

Expected behavior 🤔

I expect the color property to fulfill the | string type and allow at least "error", "warning" and "success" as valid values for it.

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo
  System:
    OS: macOS 13.4.1
  Binaries:
    Node: 18.17.1 - ~/.n/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.6.7 - ~/.n/bin/npm
  Browsers:
    Chrome: 116.0.5845.187
    Edge: Not Found
    Safari: 16.5.2
  npmPackages:
    @emotion/react: 11.11.1 => 11.11.1
    @emotion/styled: 11.11.0 => 11.11.0
    @mui/base:  5.0.0-beta.15
    @mui/core-downloads-tracker:  5.14.9
    @mui/icons-material: 5.14.9 => 5.14.9
    @mui/material: 5.14.9 => 5.14.9
    @mui/private-theming:  5.14.9
    @mui/styled-engine:  5.14.9
    @mui/system:  5.14.9
    @mui/types:  7.2.4
    @mui/utils:  5.14.9
    @types/react: 18.2.21 => 18.2.21
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    typescript: 5.2.2 => 5.2.2
@BreakBB BreakBB added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 19, 2023
@zannager zannager added component: app bar This is the name of the generic UI component, not the React module! typescript labels Sep 19, 2023
@ttlpta
Copy link
Contributor

ttlpta commented Sep 19, 2023

image
@BreakBB You can workaround by declare interface AppBarPropsColorOverrides

@danilo-leal danilo-leal added the package: material-ui Specific to @mui/material label Sep 19, 2023
@BreakBB
Copy link
Contributor Author

BreakBB commented Sep 20, 2023

Thanks @ttlpta that is something for the meantime and better than @ts-ignore 😅 👍🏻

@ttlpta
Copy link
Contributor

ttlpta commented Sep 20, 2023

@BreakBB It seems this is the official solution to add customized color to any component https://mui.com/material-ui/customization/theme-components/#creating-new-component-variants

@BreakBB
Copy link
Contributor Author

BreakBB commented Sep 21, 2023

@BreakBB It seems this is the official solution to add customized color to any component https://mui.com/material-ui/customization/theme-components/#creating-new-component-variants

Well yeah for any custom colors I am totally fine with this method. But in my opinion the error, warning and success colors should be valid color options by default. I might be wrong, but hence this issue.

@ZeeshanTamboli ZeeshanTamboli changed the title [AppBar][Typescript] color property does not support "error", "warning" and "success" [AppBar][material-ui] Type error for color property with "error", "warning" and "success" values Oct 10, 2023
@ZeeshanTamboli
Copy link
Member

@BreakBB Thanks for reporting the bug. It's a straightforward fix. Would you like to create a PR? You can follow the approach used in #39058, which addressed a similar issue with the Slider's color prop.

@ZeeshanTamboli ZeeshanTamboli added good first issue Great for first contributions. Enable to learn the contribution process. bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 10, 2023
@BreakBB
Copy link
Contributor Author

BreakBB commented Oct 11, 2023

@BreakBB Thanks for reporting the bug. It's a straightforward fix. Would you like to create a PR? You can follow the approach used in #39058, which addressed a similar issue with the Slider's color prop.

Yes, absolutely. Thanks for the guiding the way with the PR you linked 👍🏻

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! good first issue Great for first contributions. Enable to learn the contribution process. package: material-ui Specific to @mui/material typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants