Skip to content

Commit

Permalink
[material-ui][responsiveFontSizes] Handled undefined variants (mui#42412
Browse files Browse the repository at this point in the history
)
  • Loading branch information
brijeshb42 authored and joserodolfofreitas committed Jul 29, 2024
1 parent ea5fe58 commit 498185c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/mui-material/src/styles/responsiveFontSizes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export default function responsiveFontSizes(themeInput, options = {}) {

variants.forEach((variant) => {
const style = typography[variant];

if (!style) {
return;
}

const remFontSize = parseFloat(convert(style.fontSize, 'rem'));

if (remFontSize <= 1) {
Expand Down
13 changes: 13 additions & 0 deletions packages/mui-material/src/styles/responsiveFontSizes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ describe('responsiveFontSizes', () => {
});
});

it('should handle variants that have been reset to undefined', () => {
const theme = createTheme({
typography: {
h1: undefined,
},
});
const { typography } = responsiveFontSizes(theme, {
disableAlign: true,
});

expect(typography.h1).to.deep.equal(undefined);
});

describe('when requesting a responsive typography with non unitless line height and alignment', () => {
it('should throw an error, as this is not supported', () => {
const theme = createTheme({
Expand Down

0 comments on commit 498185c

Please sign in to comment.