Skip to content

Commit

Permalink
feat(radioGroup): support data-* and aria-* props (#30507)
Browse files Browse the repository at this point in the history
close #30501
  • Loading branch information
kerm1it committed May 13, 2021
1 parent 1bcb123 commit 04479b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions components/radio/__tests__/group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
2 changes: 2 additions & 0 deletions components/radio/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -91,6 +92,7 @@ const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>((props, ref
);
return (
<div
{...getDataOrAriaProps(props)}
className={classString}
style={style}
onMouseEnter={onMouseEnter}
Expand Down

0 comments on commit 04479b8

Please sign in to comment.