diff --git a/src/views/search/components/filter-section-item.tsx b/src/views/search/components/filter-section-item.tsx index bb6409b1..6bbc65b0 100644 --- a/src/views/search/components/filter-section-item.tsx +++ b/src/views/search/components/filter-section-item.tsx @@ -1,7 +1,9 @@ import { VNode } from "preact"; import { CheckboxBox } from "components/checkbox-box/checkbox-box"; -import { VisuallyHidden } from "react-aria"; +import { useCheckbox, VisuallyHidden } from "react-aria"; import style from "./filter-section-item.module.scss"; +import { useToggleState } from "react-stately"; +import { useRef } from "preact/hooks"; interface FilterSectionItemProps { icon: VNode; @@ -18,12 +20,23 @@ export const FilterSectionItem = ({ selected, onChange, }: FilterSectionItemProps) => { + const props = { + isSelected: selected, + onChange: onChange, + }; + + const state = useToggleState(props); + + const ref = useRef(null); + const { inputProps } = useCheckbox(props, state, ref); + const isSelected = state.isSelected; + return ( ( )}