feat(radioGroup): support data-* and aria-* props (#30507)

close #30501
This commit is contained in:
Kermit 2021-05-13 22:34:42 +08:00 committed by GitHub
parent 1bcb123035
commit 04479b8e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -192,4 +192,15 @@ describe('Radio Group', () => {
});
});
});
it('should support data-* or aria-* props', () => {
const wrapper = mount(
createRadioGroup({
'data-radio-group-id': 'radio-group-id',
'aria-label': 'radio-group',
}),
);
expect(wrapper.getDOMNode().getAttribute('data-radio-group-id')).toBe('radio-group-id');
expect(wrapper.getDOMNode().getAttribute('aria-label')).toBe('radio-group');
});
});

View File

@ -6,6 +6,7 @@ import { RadioGroupProps, RadioChangeEvent, RadioGroupButtonStyle } from './inte
import { ConfigContext } from '../config-provider';
import SizeContext from '../config-provider/SizeContext';
import { RadioGroupContextProvider } from './context';
import getDataOrAriaProps from '../_util/getDataOrAriaProps';
const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>((props, ref) => {
const { getPrefixCls, direction } = React.useContext(ConfigContext);
@ -91,6 +92,7 @@ const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>((props, ref
);
return (
<div
{...getDataOrAriaProps(props)}
className={classString}
style={style}
onMouseEnter={onMouseEnter}