Skip to content

Commit e0ae00f

Browse files
Add fallback className to component guards
1 parent 8f12383 commit e0ae00f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/components/content-presentation/notification-banner/NotificationBanner.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,21 @@ const NotificationBannerComponent = forwardRef<HTMLDivElement, NotificationBanne
3939
}, [moduleRef, instance]);
4040

4141
const items = Children.toArray(children);
42+
4243
const titleElement = items.find((child) =>
43-
childIsOfComponentType(child, NotificationBannerTitle),
44-
);
45-
const nonTitleItems = items.filter(
46-
(child) => !childIsOfComponentType(child, NotificationBannerTitle),
47-
);
48-
const headerElement = nonTitleItems.find((child) =>
49-
childIsOfComponentType(child, NotificationBannerHeading),
44+
childIsOfComponentType(child, NotificationBannerTitle, {
45+
className: 'nhsuk-notification-banner__title',
46+
}),
5047
);
51-
const bodyItems = nonTitleItems.filter(
52-
(child) => !childIsOfComponentType(child, NotificationBannerHeading),
48+
49+
const headerElement = items.find((child) =>
50+
childIsOfComponentType(child, NotificationBannerHeading, {
51+
className: 'nhsuk-notification-banner__heading',
52+
}),
5353
);
5454

55+
const bodyItems = items.filter((child) => child !== titleElement && child !== headerElement);
56+
5557
if (instanceError) {
5658
throw instanceError;
5759
}

0 commit comments

Comments
 (0)