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

responsiveFontSizes crashes when one of the variants is disabled #42252

Closed
SrMatheus2000 opened this issue May 15, 2024 · 4 comments · Fixed by #42412
Closed

responsiveFontSizes crashes when one of the variants is disabled #42252

SrMatheus2000 opened this issue May 15, 2024 · 4 comments · Fixed by #42412
Assignees
Labels
customization: theme Centered around the theming features package: system Specific to @mui/system

Comments

@SrMatheus2000
Copy link

SrMatheus2000 commented May 15, 2024

Steps to reproduce

Link to live example:
https://stackblitz.com/edit/github-o8g8fe?file=src%2FApp.tsx

Steps:

  1. Create a theme
  2. Mark one of the default typography variants as undefined
  3. use responsiveFontSizes on the theme

Current behavior

When using the responsiveFontSizes on a theme where a default typography variant is disabled, the function crashs

Expected behavior

responsiveFontSizes should just ignore disabled variants and not crash

Context

I created a custom theme, with custom typography variants and disabled the default ones by marking them as undefined in the createTheme. and used the responsiveFontSizes to make the new variants as responsive, and it crashed

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
   System:
    OS: Windows 11 10.0.22635
  Binaries:
    Node: 18.20.2 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: Not Found
  Browsers:
    Chrome: 124.0.6367.203
  npmPackages:
    @emotion/react: ^11.11.3 => 11.11.4
    @emotion/styled: ^11.11.0 => 11.11.5
    @mui/base:  5.0.0-beta.40
    @mui/core-downloads-tracker:  5.15.17
    @mui/icons-material: ^5.15.4 => 5.15.17
    @mui/material:  5.15.17
    @mui/private-theming:  5.15.14
    @mui/styled-engine:  5.15.14
    @mui/system:  5.15.15
    @mui/types:  7.2.14
    @mui/utils:  5.15.14
    @mui/x-data-grid:  6.19.11
    @mui/x-date-pickers:  6.19.9
    @types/react:  18.3.2
    react:  18.3.1
    react-dom:  18.3.1
    typescript: ^5.3.3 => 5.4.5

Search keywords: responsiveFontSizes, crash

@SrMatheus2000 SrMatheus2000 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 15, 2024
@zannager zannager added customization: theme Centered around the theming features package: system Specific to @mui/system labels May 16, 2024
@brijeshb42
Copy link
Contributor

This is to be expected since we spread those variant definitions in a lot of places and there are no undefined checks. You could instead try to make them as empty object ({}) instead of undefined and see if that works.

@brijeshb42 brijeshb42 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 May 17, 2024
@SrMatheus2000
Copy link
Author

But this way I cant have the type as undefined in Typescript, right? and so this variants will still show up in the typography as valid options, right?

@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 May 21, 2024
@SrMatheus2000
Copy link
Author

Also, just for completeness, the documentation says to use "undefined" to disable a variant: https://mui.com/material-ui/customization/typography/#adding-amp-disabling-variants

@brijeshb42
Copy link
Contributor

so this variants will still show up in the typography as valid options, right?

That is true. We'll need to handle undefined case in the library code.

@oliviertassinari oliviertassinari removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: theme Centered around the theming features package: system Specific to @mui/system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants