Skip to content

Commit ed03fb4

Browse files
committed
react-native(HeaderRoot): suppress title row when title === false; restore isReactNodeRenderable checks for title/accessory
1 parent f169d28 commit ed03fb4

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • packages/design-system-react-native/src/components/HeaderRoot

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Box, BoxAlignItems, BoxFlexDirection } from '../Box';
77
import { BoxRow } from '../BoxRow';
88
import { ButtonIcon, ButtonIconSize } from '../ButtonIcon';
99
import { TextVariant } from '../Text';
10+
import { isReactNodeRenderable } from '@metamask/design-system-shared';
1011

1112
// Internal dependencies.
1213
import type { HeaderRootProps } from './HeaderRoot.types';
@@ -49,16 +50,21 @@ export const HeaderRoot = ({
4950
if (children) {
5051
return children;
5152
}
52-
if (title || titleAccessory) {
53+
const hasTitleContent =
54+
title !== false &&
55+
(isReactNodeRenderable(title) || isReactNodeRenderable(titleAccessory));
56+
if (hasTitleContent) {
5357
return (
5458
<BoxRow
55-
endAccessory={titleAccessory}
59+
endAccessory={
60+
isReactNodeRenderable(titleAccessory) ? titleAccessory : undefined
61+
}
5662
textProps={{
5763
variant: TextVariant.HeadingLg,
5864
...titleProps,
5965
}}
6066
>
61-
{title || null}
67+
{isReactNodeRenderable(title) ? title : null}
6268
</BoxRow>
6369
);
6470
}

0 commit comments

Comments
 (0)