diff --git a/packages/toggleBox/components/ToggleBoxGroup.tsx b/packages/toggleBox/components/ToggleBoxGroup.tsx
index 4fd997a40..d8dd87989 100644
--- a/packages/toggleBox/components/ToggleBoxGroup.tsx
+++ b/packages/toggleBox/components/ToggleBoxGroup.tsx
@@ -43,6 +43,17 @@ export interface ToggleBoxGroupProps {
label?: React.ReactNode;
}
+const ToggleBoxWrapper = ({ label, children }) => {
+ return label ? (
+
+ ) : (
+ children
+ );
+};
+
const ToggleBoxGroup = ({
children,
direction = "row",
@@ -60,41 +71,34 @@ const ToggleBoxGroup = ({
return selectedItems.filter(selectedChoice => selectedChoice !== value);
};
- const ToggleBoxes = () => (
-
- {React.Children.toArray(children).map(toggleBox => {
- const { name, value, ...childProps } = toggleBox.props;
- const handleChange = e => {
- onChange?.(getSelectedItems(value, e.target.checked));
- };
+ return (
+
+
+ {React.Children.toArray(children).map(toggleBox => {
+ const { name, value, ...childProps } = toggleBox.props;
+ const handleChange = e => {
+ onChange?.(getSelectedItems(value, e.target.checked));
+ };
- return (
-
- {React.cloneElement(toggleBox, {
- name: multiSelect ? name : name || id,
- type: multiSelect ? "checkbox" : "radio",
- onChange: handleChange,
- isActive: selectedItems.includes(value),
- id: childProps.id,
- value,
- ...childProps
- })}
-
- );
- })}
-
- );
-
- return label ? (
-
- ) : (
-
+ return (
+
+ {React.cloneElement(toggleBox, {
+ name: multiSelect ? name : name || id,
+ type: multiSelect ? "checkbox" : "radio",
+ onChange: handleChange,
+ isActive: selectedItems.includes(value),
+ id: childProps.id,
+ value,
+ ...childProps
+ })}
+
+ );
+ })}
+
+
);
};