Skip to content

Commit 00fadd4

Browse files
tacckjjarvisp
andauthored
fix: Numeric 0 can be set in the property (#6381)
Co-authored-by: James Jarvis <[email protected]>
1 parent 81543cb commit 00fadd4

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Diff for: .changeset/eight-socks-approve.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aws-amplify/ui-react": patch
3+
---
4+
5+
fix: Numeric 0 can be set in the property

Diff for: packages/react/src/primitives/shared/__tests__/styleUtils.test.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ describe('convertStylePropsToStyleObj:', () => {
6767
// cast to `undefined` to allow robustness testing
6868
color: null as unknown as undefined,
6969
border: '',
70+
borderWidth: 0,
7071
borderRadius: '6px',
7172
ariaLabel: 'important section',
7273
as: 'section',
@@ -80,6 +81,7 @@ describe('convertStylePropsToStyleObj:', () => {
8081
expect(propStyles['backgroundColor']).toBeUndefined();
8182
expect(propStyles['color']).toBeUndefined();
8283
expect(propStyles['border']).toBeUndefined();
84+
expect(propStyles['borderWidth']).toBe(props.borderWidth);
8385
expect(propStyles['borderRadius']).toBe(props.borderRadius);
8486
expect(propStyles['as']).toBeUndefined();
8587
});

Diff for: packages/react/src/primitives/shared/styleUtils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ export const convertStylePropsToStyleObj: ConvertStylePropsToStyleObj = ({
128128
.forEach((propKey) => {
129129
if (isComponentStyleProp(propKey)) {
130130
const values = props[propKey];
131-
if (!values || isEmptyString(values)) return;
131+
if (values === null || values === undefined || isEmptyString(values))
132+
return;
132133

133134
const reactStyleProp = ComponentPropsToStylePropsMap[propKey];
134135
// short circuit the style prop here if it is a string or design token

0 commit comments

Comments
 (0)