Skip to content

Commit b1da0c7

Browse files
author
Luke Bowerman
authored
fix(ListItem): Prevent props from being spuriously emitted to DOM output (#2086)
1 parent ae5bc1b commit b1da0c7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/components/src/List/ListItem.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import 'jest-styled-components'
2828
import React from 'react'
2929
import { renderWithTheme } from '@looker/components-test-utils'
30-
import { fireEvent, configure } from '@testing-library/react'
30+
import { fireEvent, configure, screen } from '@testing-library/react'
3131

3232
import { ListItem } from './ListItem'
3333

@@ -38,17 +38,17 @@ describe('ListItem', () => {
3838
})
3939

4040
test('renders description', () => {
41-
const { getByText } = renderWithTheme(
42-
<ListItem description="are you?">who!</ListItem>
43-
)
44-
expect(getByText('are you?')).toBeVisible()
41+
renderWithTheme(<ListItem description="are you?">who!</ListItem>)
42+
expect(screen.getByText('are you?')).toBeVisible()
43+
expect(screen.getByRole('listitem')).not.toHaveAttribute('description')
4544
})
4645

4746
test('renders detail', () => {
4847
const { getByText } = renderWithTheme(
4948
<ListItem detail="Is an excellent question">who!</ListItem>
5049
)
5150
expect(getByText('Is an excellent question')).toBeVisible()
51+
expect(screen.getByRole('listitem')).not.toHaveAttribute('detail')
5252
})
5353

5454
test('renders icon', () => {

packages/components/src/List/ListItemWrapper.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
2525
*/
2626

27-
import { CompatibleHTMLProps } from '@looker/design-tokens'
27+
import { CompatibleHTMLProps, shouldForwardProp } from '@looker/design-tokens'
2828
import omit from 'lodash/omit'
2929
import React, { forwardRef, ReactNode, Ref } from 'react'
3030
import styled from 'styled-components'
@@ -66,7 +66,11 @@ const ListItemWrapperInternal = forwardRef(
6666

6767
ListItemWrapperInternal.displayName = 'ListItemWrapperInternal'
6868

69-
export const ListItemWrapper = styled(ListItemWrapperInternal)`
69+
export const ListItemWrapper = styled(
70+
ListItemWrapperInternal
71+
).withConfig<ListItemWrapperProps>({
72+
shouldForwardProp,
73+
})`
7074
align-items: center;
7175
color: ${({ theme: { colors } }) => colors.text5};
7276
display: flex;

0 commit comments

Comments
 (0)