Skip to content

Commit 78ec92d

Browse files
Luke BowermanLuke Bowerman
authored andcommitted
ModalHeader now properly passes through DOM properties (id, aria-label)
1 parent 0cf3b6b commit 78ec92d

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

packages/components/src/Modal/Layout/ModalHeader.test.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626

2727
import 'jest-styled-components'
2828
import React from 'react'
29-
import { assertSnapshot, mountWithTheme } from '@looker/components-test-utils'
29+
import {
30+
assertSnapshot,
31+
mountWithTheme,
32+
renderWithTheme,
33+
} from '@looker/components-test-utils'
3034
import { IconButton } from '../../Button'
3135
import { ModalHeader } from './ModalHeader'
3236

@@ -36,6 +40,16 @@ test('ModalHeader', () => {
3640
)
3741
})
3842

43+
test('ModalHeader passes through DOM props', () => {
44+
const { findByLabelText } = renderWithTheme(
45+
<ModalHeader aria-label="This is the ARIA label">
46+
The Heading for a Dialog
47+
</ModalHeader>
48+
)
49+
50+
expect(findByLabelText('This is the ARIA label')).toBeTruthy()
51+
})
52+
3953
test('ModalHeader with hideClose', () => {
4054
const withClose = mountWithTheme(
4155
<ModalHeader id="test-modalHeader">The Heading for a Dialog</ModalHeader>

packages/components/src/Modal/Layout/ModalHeader.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ import React, { FC, useContext, ReactElement } from 'react'
2828
import { IconNames } from '@looker/icons'
2929
import styled from 'styled-components'
3030
import {
31+
CompatibleHTMLProps,
32+
omitStyledProps,
3133
SpaceProps,
3234
space,
33-
CompatibleHTMLProps,
3435
reset,
3536
} from '@looker/design-tokens'
3637

@@ -56,22 +57,20 @@ export interface ModalHeaderProps
5657
* Render an icon next to the title text
5758
*/
5859
headerIcon?: ReactElement<IconProps>
59-
60-
className?: string
6160
}
6261

6362
const ModalHeaderLayout: FC<ModalHeaderProps> = ({
64-
className,
6563
children,
6664
closeIcon = 'Close',
6765
hideClose,
6866
headerIcon,
69-
id,
67+
...props
7068
}) => {
7169
const { closeModal } = useContext(ModalContext)
70+
const { id } = props
7271

7372
return (
74-
<header className={className}>
73+
<header {...omitStyledProps(props)}>
7574
{headerIcon && <HeaderIconWrapper>{headerIcon}</HeaderIconWrapper>}
7675
<Heading
7776
as="h3"

packages/components/src/Modal/Layout/__snapshots__/ModalHeader.test.tsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ exports[`ModalHeader 1`] = `
128128
129129
<header
130130
className="c0"
131+
id="test-modalHeader"
131132
>
132133
<h3
133134
className="c1"

0 commit comments

Comments
 (0)