Skip to content

Commit

Permalink
FIX TextCheckboxGroupField should passthrough if it has only one child
Browse files Browse the repository at this point in the history
  • Loading branch information
ScopeyNZ authored and robbieaverill committed Nov 20, 2018
1 parent a0ec072 commit c1a1c45
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@ import { InputGroup, InputGroupAddon, InputGroupText } from 'reactstrap';
import fieldHolder from 'components/FieldHolder/FieldHolder';

const TextCheckboxGroupField = (props) => {
const { children } = props;
const { children } = props;

const childrenWithProps = React.Children.toArray(
React.Children.map(children, child =>
React.cloneElement(child, { noHolder: true })
)
);
return (
<InputGroup className="text-checkout-group-field">
{childrenWithProps[0]}
<InputGroupAddon addonType="append">
<InputGroupText>{childrenWithProps[1]}</InputGroupText>
</InputGroupAddon>
</InputGroup>
);
const childrenWithProps = React.Children.toArray(
React.Children.map(children, child =>
React.cloneElement(child, { noHolder: true })
)
);

if (childrenWithProps.length === 1) {
return childrenWithProps[0];
}

return (
<InputGroup className="text-checkout-group-field">
{childrenWithProps[0]}
<InputGroupAddon addonType="append">
<InputGroupText>{childrenWithProps[1]}</InputGroupText>
</InputGroupAddon>
</InputGroup>
);
};

export default fieldHolder(TextCheckboxGroupField);

0 comments on commit c1a1c45

Please # to comment.