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][Link] TypeError: color.charAt is not a function error message #44900

Closed
andreachiera opened this issue Dec 30, 2024 · 4 comments · Fixed by #44927
Closed

[material-ui][Link] TypeError: color.charAt is not a function error message #44900

andreachiera opened this issue Dec 30, 2024 · 4 comments · Fixed by #44927
Assignees
Labels
bug 🐛 Something doesn't work component: link This is the name of the generic UI component, not the React module!

Comments

@andreachiera
Copy link

andreachiera commented Dec 30, 2024

Steps to reproduce

I have defined some new colors under the colorSchemes prop, in particular two new color Schemes light and dark. For each of them I defined some new colors using the augmentColor utility obtained in this way:

let MyTheme = createTheme();
MyTheme = createTheme({
colorSchemes: {
   light: {
     myColor: MyTheme.palette.augmentColor({ { main: "#ffffff" }, "myColor" })
  },
  dark: {
     myColor: MyTheme.palette.augmentColor({ { main: "#cccccc" }, "myColor" })
  }
}
})

I'm using typescript, so I used the module augmentation before the first createTheme to extends the needed interfaces:

declare module '@mui/material/styles' {
    interface Palette {
        myColor: Palette['primary'];
    }

    interface PaletteOptions {
        myColor?: PaletteOptions['primary'];
    }
}

declare module '@mui/material/Typography' {
    interface TypographyPropsColorOverrides {
        myColor: true;
    }
}

And finally I applied a default prop to the Link component:

MyTheme = createTheme(MyTheme, {
    components:{
        MuiLink: {
           defaultProps: {
        underline: "always",
        color: "myColor"
    }
      }
    }
})

An error is thrown when I try to start my NextJs project. If I change the value of the defaultProps underline from always to hover, it works.

The error:
image

Current behavior

No response

Expected behavior

No response

Context

No response

Your environment

Browser: Edge

Dependencies:
"next": "^15.0.3",
both material and material-nextjs at version 6.3.0

Search keywords: A similar issue: #41772

@andreachiera andreachiera added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 30, 2024
@zannager zannager added the component: link This is the name of the generic UI component, not the React module! label Dec 30, 2024
@samuelsycamore
Copy link
Contributor

Hi @andreachiera, can you share a minimal reproduction of the problem you're facing (GH repo, CodeSandbox, or similar)? This will help the maintainers to sort things out more effectively.

@samuelsycamore samuelsycamore 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 Dec 30, 2024
@andreachiera
Copy link
Author

andreachiera commented Dec 31, 2024

Hi.
Codesandbox: https://codesandbox.io/p/devbox/hardcore-panna-tqy2gc
If you comment the line 40 of the file under app/theme.config.ts and remove the comment at line 41 enabling the hover behavior, it works.

@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 Dec 31, 2024
@DiegoAndai DiegoAndai assigned siriwatknp and unassigned mj12albert Jan 2, 2025
@siriwatknp siriwatknp added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 3, 2025
@siriwatknp
Copy link
Member

The root cause is that the getTextDecoration does not work with custom palette, I am fixing it.

Copy link

github-actions bot commented Jan 6, 2025

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@andreachiera How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

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: link This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants