diff --git a/packages/react-core/src/components/List/ListItem.tsx b/packages/react-core/src/components/List/ListItem.tsx index 993c2ea97e4..5164c26b5f2 100644 --- a/packages/react-core/src/components/List/ListItem.tsx +++ b/packages/react-core/src/components/List/ListItem.tsx @@ -18,7 +18,7 @@ export const ListItem: React.FunctionComponent = ({ }: ListItemProps) => (
  • {icon && {icon}} - {children} + {icon ? {children} : children}
  • ); ListItem.displayName = 'ListItem'; diff --git a/packages/react-core/src/components/List/__tests__/ListItem.test.tsx b/packages/react-core/src/components/List/__tests__/ListItem.test.tsx index fe099c79c11..b3fd702056a 100644 --- a/packages/react-core/src/components/List/__tests__/ListItem.test.tsx +++ b/packages/react-core/src/components/List/__tests__/ListItem.test.tsx @@ -1,5 +1,6 @@ import { render, screen } from '@testing-library/react'; import { ListItem } from '../ListItem'; +import { Content } from '../../Content'; import styles from '@patternfly/react-styles/css/components/List/list'; test('Renders with children', () => { @@ -8,6 +9,16 @@ test('Renders with children', () => { expect(screen.getByRole('listitem')).toHaveTextContent('List item content'); }); +test('Renders block content without an inline wrapper when there is no icon', () => { + render( + + List item content + + ); + + expect(screen.getByTestId('content').parentElement).toBe(screen.getByRole('listitem')); +}); + test(`Does not render with a class by default`, () => { render(List item content); diff --git a/packages/react-core/src/components/List/__tests__/__snapshots__/ListItem.test.tsx.snap b/packages/react-core/src/components/List/__tests__/__snapshots__/ListItem.test.tsx.snap index 867f8836e2b..11f6b5d21ad 100644 --- a/packages/react-core/src/components/List/__tests__/__snapshots__/ListItem.test.tsx.snap +++ b/packages/react-core/src/components/List/__tests__/__snapshots__/ListItem.test.tsx.snap @@ -24,9 +24,7 @@ exports[`Matches snapshot with icon 1`] = ` exports[`Matches snapshot without icon 1`] = `
  • - - List item content - + List item content
  • `;