mirror of
https://github.com/react95-io/React95.git
synced 2026-04-26 03:00:18 -04:00
forward ref to radio
This commit is contained in:
@@ -91,18 +91,19 @@ const Icon = styled.span.attrs(() => ({
|
||||
isDisabled ? theme.checkmarkDisabled : theme.checkmark};
|
||||
`;
|
||||
|
||||
const Radio = ({
|
||||
onChange,
|
||||
label,
|
||||
disabled,
|
||||
variant,
|
||||
value,
|
||||
checked,
|
||||
name,
|
||||
className,
|
||||
style,
|
||||
...otherProps
|
||||
}) => {
|
||||
const Radio = React.forwardRef(function Radio(props, ref) {
|
||||
const {
|
||||
onChange,
|
||||
label,
|
||||
disabled,
|
||||
variant,
|
||||
value,
|
||||
checked,
|
||||
name,
|
||||
className,
|
||||
style,
|
||||
...otherProps
|
||||
} = props;
|
||||
const CheckboxComponent =
|
||||
variant === 'flat' ? StyledFlatCheckbox : StyledCheckbox;
|
||||
|
||||
@@ -124,11 +125,12 @@ const Radio = ({
|
||||
value={value}
|
||||
checked={checked}
|
||||
name={name}
|
||||
ref={ref}
|
||||
{...otherProps}
|
||||
/>
|
||||
</StyledLabel>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
Radio.defaultProps = {
|
||||
onChange: undefined,
|
||||
|
||||
@@ -71,7 +71,6 @@ describe('<Radio />', () => {
|
||||
expect(checkbox.checked).toBe(false);
|
||||
expect(getByRole('radio')).not.toHaveAttribute('checked');
|
||||
expect(getByRole('presentation').firstChild).toBeNull();
|
||||
// check if proper icon was rendered
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user