Skip to content

Commit

Permalink
fix: make TagBody render as span rather than p (#2533)
Browse files Browse the repository at this point in the history
  • Loading branch information
kark authored Jun 2, 2023
1 parent daab774 commit 4474bf7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-boats-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-uikit/tag': patch
---

Make `<TagBody>` render as `<span>` rather than `<p>`
4 changes: 3 additions & 1 deletion packages/components/tag/src/tag-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ const TagBody = (props: TTagBodyProps) => {
{props.isDraggable && !props.isDisabled ? (
<DragIcon data-testid="drag-icon" size="medium" />
) : null}
<Text.Body tone={textTone}>{props.children}</Text.Body>
<Text.Body tone={textTone} as="span">
{props.children}
</Text.Body>
</Spacings.Inline>
</Body>
);
Expand Down
14 changes: 13 additions & 1 deletion packages/components/tag/src/tag.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import { screen, render } from '../../../../test/test-utils';
import Tag from './tag';

it('should render children', () => {
it('should render text as children', () => {
render(<Tag>Bread</Tag>);
expect(screen.getByText('Bread')).toBeInTheDocument();
});
it('should render html markup as children', () => {
const error = jest.spyOn(console, 'error').mockImplementation(() => {});
render(
<Tag>
<div>👋</div>
</Tag>
);

// ensure is renders correctly without validateDOMNesting warning
expect(screen.getByText('👋')).toBeInTheDocument();
expect(error).not.toHaveBeenCalled();
});

it('should call onClick when clicked', () => {
const onClick = jest.fn();
Expand Down

1 comment on commit 4474bf7

@vercel
Copy link

@vercel vercel bot commented on 4474bf7 Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.