Typography variantMapping should merge with the default value
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
variantMapping es sobreescrito por defaultVariantMapping estropeando la variantMapping propiedad.
Se podría cambiar esta linea por
variantMapping["defaultVariantMapping"] = defaultVariantMapping,

En esta linea variantMapping[variant] no se lee nunca porque las propiedades quedan sobre escritas.
https://github.com/mui/material-ui/blob/92a4866ce9a06769592cddc06cfa7455b4644544/packages/mui-material/src/Typography/Typography.js#L121
Expected behavior 🤔
Que variantMapping funcione de manera correcta, sin tener que usar la api de componentes.
Steps to reproduce 🕹
Crear un tema y probar las opciones de typography con diferentes api
typography: {
fontFamily: "libre franklin",
"em":styleText(400 ,{name: "backgroundColor", value:"lawngreen"}),
/*
variantMapping: {
"em": 'em',
},*/
defaultProps: {
variantMapping: {
"em": 'em',
},
},
},
components: {
MuiTypography: {
variants: [
{
props: { variant: 'mark' },
style: {
backgroundColor:"lightskyblue",
},
},
],
/* Nofunciona
variantMapping: {
"mark": 'mark',
},
*/
defaultProps: {
variantMapping: {
subtitle1: 'header',
subtitle2: 'header',
"mark": 'mark',
"em": 'em',
},
},
},
},
Context 🔦
Al ver porque usabais defaultProps me di cuenta de este error.
Your environment 🌎
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/mui-material/src/Typography/Typography.js at the referenced lines and reproduce the issue with a theme's Typography defaultProps and variantMapping. Verify how the default mapping is applied and confirm that custom variant entries remain available alongside defaults when the fix is complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100