From 199cd762978cbbb10b70948fb7829f9d43de1e05 Mon Sep 17 00:00:00 2001 From: akash-dabhi-qed Date: Wed, 15 Apr 2026 13:29:58 +0530 Subject: [PATCH] fix: guard against undefined theme size in Button for XS variant --- .../src/components/Button/Button.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/design-system/src/components/Button/Button.tsx b/packages/design-system/src/components/Button/Button.tsx index f6b13ce66..bdfdfa45d 100644 --- a/packages/design-system/src/components/Button/Button.tsx +++ b/packages/design-system/src/components/Button/Button.tsx @@ -115,19 +115,20 @@ const ButtonWrapper = styled>(Flex)` ${({ theme, $size }) => { const sizeValue = theme.sizes.button[$size]; + if (!sizeValue) return ''; + if (typeof sizeValue === 'string') { return `height: ${sizeValue};`; } const styles: string[] = []; Object.entries(sizeValue).forEach(([breakpoint, breakpointValue]) => { - if (breakpointValue) { - if (breakpoint === 'initial') { - styles.push(`height: ${breakpointValue};`); - } else if (breakpoint in theme.breakpoints) { - const breakpointQuery = theme.breakpoints[breakpoint as keyof typeof theme.breakpoints]; - styles.push(`${breakpointQuery} { height: ${breakpointValue}; }`); - } + if (!breakpointValue) return; + if (breakpoint === 'initial') { + styles.push(`height: ${breakpointValue};`); + } else if (breakpoint in theme.breakpoints) { + const breakpointQuery = theme.breakpoints[breakpoint as keyof typeof theme.breakpoints]; + styles.push(`${breakpointQuery} { height: ${breakpointValue}; }`); } });