Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/eui/changelogs/upcoming/8586.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Spread `labelProps` to the `label` element in `EuiCheckableCard`
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,22 @@ describe('EuiCheckableCard', () => {

expect(container.firstChild).toMatchSnapshot();
});

test('applies labelProps to the label element', () => {
const labelProps = {
'data-test-subj': 'testLabel',
title: 'Test Title',
};

const { getByText } = render(
<EuiCheckableCard
{...checkablePanelRequiredProps}
labelProps={labelProps}
/>
);

const labelElement = getByText('Label');
expect(labelElement).toHaveAttribute('data-test-subj', 'testLabel');
expect(labelElement).toHaveAttribute('title', 'Test Title');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const EuiCheckableCard: FunctionComponent<EuiCheckableCardProps> = ({
css,
checkableType = 'radio',
label,
labelProps,
checked,
disabled,
hasShadow,
Expand Down Expand Up @@ -118,6 +119,7 @@ export const EuiCheckableCard: FunctionComponent<EuiCheckableCardProps> = ({
</EuiSplitPanel.Inner>
<EuiSplitPanel.Inner>
<label
{...labelProps}
ref={labelEl}
className={labelClasses}
css={labelStyles}
Expand Down
2 changes: 1 addition & 1 deletion packages/eui/src/components/form/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface EuiCheckboxProps
disabled?: boolean;
indeterminate?: boolean;
/**
* Object of props passed to the <label/>
* Object of props passed to the `label` element
*/
labelProps?: CommonProps & LabelHTMLAttributes<HTMLLabelElement>;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/eui/src/components/form/radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface RadioProps {
disabled?: boolean;
onChange: ChangeEventHandler<HTMLInputElement>;
/**
* Object of props passed to the <label/>
* Object of props passed to the `label` element
*/
labelProps?: CommonProps & LabelHTMLAttributes<HTMLLabelElement>;
}
Expand Down