Skip to content

Commit

Permalink
Fix count in CheckboxSelect (stashapp#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash authored and feederbox826 committed Nov 15, 2023
1 parent c27f0a8 commit 87a0925
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/src/components/checkboxSelect/CheckboxSelect.tsx
Original file line number Diff line number Diff line change
@@ -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[];
Expand All @@ -26,7 +27,9 @@ const CheckboxSelect: FC<MultiSelectProps> = ({
const [unselected, setUnselected] = useState<string[]>(initialSelected);

const handleChange = (vals: OnChangeValue<IOptionType, true>) => {
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);
Expand Down

0 comments on commit 87a0925

Please sign in to comment.