fix(Descriptions): pass all props to the Descriptions container (#40859)

This commit is contained in:
Yurii Brusentsov 2023-02-22 10:17:21 +02:00 committed by GitHub
parent f9a38af179
commit 40a7e7a142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -256,4 +256,15 @@ describe('Descriptions', () => {
);
expect(wrapper.container.firstChild).toMatchSnapshot();
});
it('should pass data-* and accessibility attributes', () => {
const { getByTestId } = render(
<Descriptions data-testid="test-id" data-id="12345" aria-describedby="some-label">
<Descriptions.Item label="banana">banana</Descriptions.Item>
</Descriptions>,
);
const container = getByTestId('test-id');
expect(container).toHaveAttribute('data-id', '12345');
expect(container).toHaveAttribute('aria-describedby', 'some-label');
});
});

View File

@ -130,6 +130,7 @@ function Descriptions({
size,
labelStyle,
contentStyle,
...restProps
}: DescriptionsProps) {
const { getPrefixCls, direction } = React.useContext(ConfigContext);
const prefixCls = getPrefixCls('descriptions', customizePrefixCls);
@ -175,6 +176,7 @@ function Descriptions({
hashId,
)}
style={style}
{...restProps}
>
{(title || extra) && (
<div className={`${prefixCls}-header`}>