Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
fix(FormRadio): only wrap in label if label is used
Browse files Browse the repository at this point in the history
  • Loading branch information
jonthomp committed Jun 1, 2018
1 parent 0d1397b commit beeacf5
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/components/Form/FormRadio.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import Form from "./";

type Props = {|
+className?: string,
/**
* Wrap the checkbox with a label
*/
+label?: string,
+value?: string | number | boolean,
+name?: string,
Expand All @@ -32,20 +35,26 @@ function FormRadio({
{ "custom-control-inline": isInline },
className
);
return (
const inputComponent = (
<Form.Input
type="radio"
name={name}
value={value}
checked={checked}
className={classes}
disabled={disabled}
readOnly={readOnly}
onChange={onChange}
/>
);

return label ? (
<label className={classes}>
<Form.Input
type="radio"
name={name}
value={value}
checked={checked}
className={classes}
disabled={disabled}
readOnly={readOnly}
onChange={onChange}
/>
{inputComponent}
<span className="custom-control-label">{label}</span>
</label>
) : (
inputComponent
);
}

Expand Down

0 comments on commit beeacf5

Please sign in to comment.