From 87a09253e5b76ac92fc0a68d76b7de347e805e4e Mon Sep 17 00:00:00 2001 From: InfiniteStash <117855276+InfiniteStash@users.noreply.github.com> Date: Fri, 27 May 2022 00:35:00 +0200 Subject: [PATCH] Fix count in CheckboxSelect (#407) --- frontend/src/components/checkboxSelect/CheckboxSelect.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/checkboxSelect/CheckboxSelect.tsx b/frontend/src/components/checkboxSelect/CheckboxSelect.tsx index 5650cf27e..829a755ca 100644 --- a/frontend/src/components/checkboxSelect/CheckboxSelect.tsx +++ b/frontend/src/components/checkboxSelect/CheckboxSelect.tsx @@ -1,6 +1,7 @@ import { FC, useState } from "react"; import Select, { OnChangeValue } from "react-select"; import { Form } from "react-bootstrap"; +import { uniq } from "lodash-es"; interface MultiSelectProps { values: IOptionType[]; @@ -26,7 +27,9 @@ const CheckboxSelect: FC = ({ const [unselected, setUnselected] = useState(initialSelected); const handleChange = (vals: OnChangeValue) => { - const selected = vals.map((v) => [v.value, ...(v.subValues ?? [])]).flat(); + const selected = uniq( + vals.map((v) => [v.value, ...(v.subValues ?? [])]).flat() + ); setUnselected(selected); onChange(selected);