Skip to content

Commit de46f72

Browse files
committed
fix(BannerBase): prevent bare numeric render by using nullish presence checks for title/description/children in RN and Web variants (handles 0 correctly) [bugfix: 496705ba-2f78-456c-8daa-4ccc689d490b]
1 parent 6c28b48 commit de46f72

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

packages/design-system-react-native/src/components/BannerBase/BannerBase.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ export const BannerBase: React.FC<BannerBaseProps> = ({
6969
{startAccessory}
7070

7171
<Box twClassName="flex-1">
72-
{title &&
72+
{title !== null &&
73+
title !== undefined &&
7374
(isTextContent(title) ? (
7475
<Text
7576
variant={TextVariant.BodyMd}
@@ -82,7 +83,7 @@ export const BannerBase: React.FC<BannerBaseProps> = ({
8283
title
8384
))}
8485

85-
{description && (
86+
{description !== null && description !== undefined && (
8687
<Box twClassName={title ? 'mt-1' : undefined}>
8788
{isTextContent(description) ? (
8889
<Text variant={TextVariant.BodySm} {...descriptionProps}>
@@ -94,7 +95,8 @@ export const BannerBase: React.FC<BannerBaseProps> = ({
9495
</Box>
9596
)}
9697

97-
{children &&
98+
{children !== null &&
99+
children !== undefined &&
98100
(isTextContent(children) ? (
99101
<Text variant={TextVariant.BodyMd} {...childrenWrapperProps}>
100102
{children}

packages/design-system-react/src/components/BannerBase/BannerBase.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ export const BannerBase = forwardRef<HTMLDivElement, BannerBaseProps>(
6666
{startAccessory}
6767

6868
<Box className="min-w-0 flex-1">
69-
{title &&
69+
{title !== null &&
70+
title !== undefined &&
7071
(isTextContent(title) ? (
7172
<Text
7273
variant={TextVariant.BodyMd}
@@ -79,7 +80,8 @@ export const BannerBase = forwardRef<HTMLDivElement, BannerBaseProps>(
7980
title
8081
))}
8182

82-
{description && (
83+
{description !== null &&
84+
description !== undefined && (
8385
<Box className={title ? 'mt-1' : undefined}>
8486
{isTextContent(description) ? (
8587
<Text variant={TextVariant.BodySm} {...descriptionProps}>
@@ -91,7 +93,8 @@ export const BannerBase = forwardRef<HTMLDivElement, BannerBaseProps>(
9193
</Box>
9294
)}
9395

94-
{children &&
96+
{children !== null &&
97+
children !== undefined &&
9598
(isTextContent(children) ? (
9699
<Text variant={TextVariant.BodyMd} {...childrenWrapperProps}>
97100
{children}

0 commit comments

Comments
 (0)