Skip to content

Commit

Permalink
fix(callout): fix callout expand in production
Browse files Browse the repository at this point in the history
Fixes issue where the Callout component content was not expanding correctly in prdouction. This is
because the property `name` is obfuscated in production for some environments. Setting and checking
for `displayName` should fix the issue because it is not obfuscated in production.
  • Loading branch information
codemonkey800 committed Jan 17, 2024
1 parent 4215898 commit 12480ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ const CalloutTitle = ({ children }: AlertTitleProps): JSX.Element => {
return <StyledCalloutTitle>{children}</StyledCalloutTitle>;
};

// Display name required to ensure Callout expand works correctly.
CalloutTitle.displayName = "CalloutTitle";

export default CalloutTitle;
4 changes: 3 additions & 1 deletion packages/components/src/core/Callout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ const Callout = ({
let calloutContent;

const firstChildIsCalloutTitle =
Array.isArray(children) && children[0]?.type?.name === "CalloutTitle";
Array.isArray(children) &&
children[0]?.type?.displayName === "CalloutTitle";

if (firstChildIsCalloutTitle) {
[calloutTitle, ...calloutContent] = children;
}
Expand Down

0 comments on commit 12480ea

Please sign in to comment.