Skip to content

Commit 569c72e

Browse files
[system] Fix handling of null-ish values (mui#24527)
1 parent 4295444 commit 569c72e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/material-ui-system/src/spacing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export function createUnarySpacing(theme) {
123123
}
124124

125125
function getValue(transformer, propValue) {
126-
if (typeof propValue === 'string') {
126+
if (typeof propValue === 'string' || propValue == null) {
127127
return propValue;
128128
}
129129

packages/material-ui-system/src/spacing.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,15 @@ describe('spacing', () => {
171171
paddingTop: '10px',
172172
});
173173
});
174+
175+
it('should allow to conditionally set a value', () => {
176+
const foo = true;
177+
const output = spacing({
178+
theme: {},
179+
pt: foo ? undefined : 2,
180+
});
181+
expect(output).to.deep.equal({
182+
paddingTop: undefined,
183+
});
184+
});
174185
});

0 commit comments

Comments
 (0)