Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BannerSlim: VR fixes when message isnt string #3940

Merged
merged 4 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/gestalt/src/BannerSlim.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentProps, Fragment, ReactElement, useRef } from 'react';
import { cloneElement, ComponentProps, Fragment, ReactElement, useRef } from 'react';
import useIsParagraph from './BannerSlim/useIsParagraph';
import Box from './Box';
import Button from './Button';
Expand Down Expand Up @@ -263,7 +263,10 @@ export default function BannerSlim({
</Text>
</Fragment>
) : null}
{typeof message !== 'string' && message}
<Fragment>
<Text ref={referenceRef} inline />
{typeof message !== 'string' && cloneElement(message, { ref: targetRef })}
</Fragment>
</Box>
</Flex.Item>

Expand Down
18 changes: 18 additions & 0 deletions packages/gestalt/src/__snapshots__/BannerSlim.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ exports[`BannerSlim renders an icon with accessibility label 1`] = `
>
test
</span>
<span
className="default alignStart breakWord Text fontSize300 fontWeightNormal"
/>
</div>
</div>
</div>
Expand Down Expand Up @@ -82,6 +85,9 @@ exports[`BannerSlim renders complex message 1`] = `
<div
className="box"
>
<span
className="default alignStart breakWord Text fontSize300 fontWeightNormal"
/>
<span
className="default alignStart breakWord Text fontSize300 fontWeightNormal"
>
Expand Down Expand Up @@ -153,6 +159,9 @@ exports[`BannerSlim renders neutral type with message 1`] = `
>
test
</span>
<span
className="default alignStart breakWord Text fontSize300 fontWeightNormal"
/>
</div>
</div>
</div>
Expand Down Expand Up @@ -212,6 +221,9 @@ exports[`BannerSlim renders non-neutral compact with accessibility label 1`] = `
>
test
</span>
<span
className="default alignStart breakWord Text fontSize300 fontWeightNormal"
/>
</div>
</div>
</div>
Expand Down Expand Up @@ -249,6 +261,9 @@ exports[`BannerSlim renders primary action and dismiss button 1`] = `
>
test
</span>
<span
className="default alignStart breakWord Text fontSize300 fontWeightNormal"
/>
</div>
</div>
<div
Expand Down Expand Up @@ -430,6 +445,9 @@ exports[`BannerSlim renders simple message with helper link 1`] = `
</a>
</span>
</span>
<span
className="default alignStart breakWord Text fontSize300 fontWeightNormal"
/>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ exports[`renders correctly with drawer 1`] = `
>
Test BannerSlim
</span>
<span
className="default alignStart breakWord Text fontSize300 fontWeightNormal"
/>
</div>
</div>
</div>
Expand Down
Loading