Skip to content

Commit

Permalink
[material-ui][responsiveFontSizes] Handled undefined variants (@brije…
Browse files Browse the repository at this point in the history
…shb42) (#42419)

Co-authored-by: Brijesh Bittu <[email protected]>
  • Loading branch information
github-actions[bot] and brijeshb42 authored May 27, 2024
1 parent 176f451 commit 3a72d07
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 3a72d07

Please sign in to comment.