Skip to content

Commit 2b825a2

Browse files
committed
fix(CFormLabel): CFormLabelProps doesn't accept htmlFor
1 parent d109bc3 commit 2b825a2

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

Diff for: packages/coreui-react/src/components/form/CFormLabel.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React, { forwardRef, HTMLAttributes } from 'react'
1+
import React, { forwardRef, AllHTMLAttributes } from 'react'
22
import PropTypes from 'prop-types'
33
import classNames from 'classnames'
44

5-
export interface CFormLabelProps extends HTMLAttributes<HTMLLabelElement> {
5+
export interface CFormLabelProps extends AllHTMLAttributes<HTMLLabelElement> {
66
/**
77
* A string of all className you want applied to the component.
88
*/

Diff for: packages/coreui-react/src/components/form/__tests__/CFormLabel.spec.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ test('CFormLabel customize className', async () => {
1515
expect(container.firstChild).toHaveClass('form-label')
1616
expect(container.firstChild).toHaveTextContent('Test')
1717
})
18+
19+
test('CFormLabel customize htmlFor', async () => {
20+
const { container } = render(<CFormLabel htmlFor="bazinga">Test</CFormLabel>)
21+
expect(container).toMatchSnapshot()
22+
expect(container.firstChild).toHaveAttribute('for', 'bazinga')
23+
expect(container.firstChild).toHaveClass('form-label')
24+
expect(container.firstChild).toHaveTextContent('Test')
25+
})

Diff for: packages/coreui-react/src/components/form/__tests__/__snapshots__/CFormLabel.spec.tsx.snap

+11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ exports[`CFormLabel customize className 1`] = `
1010
</div>
1111
`;
1212

13+
exports[`CFormLabel customize htmlFor 1`] = `
14+
<div>
15+
<label
16+
class="form-label"
17+
for="bazinga"
18+
>
19+
Test
20+
</label>
21+
</div>
22+
`;
23+
1324
exports[`loads and displays CFormLabel component 1`] = `
1425
<div>
1526
<label

0 commit comments

Comments
 (0)