From 108c636041e0224743d7f932ae799b70540f1232 Mon Sep 17 00:00:00 2001 From: Arlindo Pereira Date: Thu, 14 Nov 2024 17:25:45 +0100 Subject: [PATCH] Code Review fixes: turn ternary into if/else block; onChange fn fix --- .../forms/fields/CheckboxGroup/CheckboxGroup.stories.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/forms/fields/CheckboxGroup/CheckboxGroup.stories.tsx b/src/components/forms/fields/CheckboxGroup/CheckboxGroup.stories.tsx index f3bce5b..78b8014 100644 --- a/src/components/forms/fields/CheckboxGroup/CheckboxGroup.stories.tsx +++ b/src/components/forms/fields/CheckboxGroup/CheckboxGroup.stories.tsx @@ -26,9 +26,11 @@ export default { render: (args) => { const [selectedColors, setSelectedColors] = React.useState>([]); const handleCheckboxChange = (color: Color) => { - selectedColors.includes(color) ? - setSelectedColors(selectedColors.filter(c => c !== color)) : + if (selectedColors.includes(color)) { + setSelectedColors(selectedColors.filter(c => c !== color)); + } else { setSelectedColors([...selectedColors, color]); + } }; return ( @@ -37,7 +39,7 @@ export default { key={color} label={color} checked={selectedColors.includes(color)} - onChange={() => handleCheckboxChange(color as Color)} + onChange={() => { handleCheckboxChange(color as Color); }} /> )}