fix(CategoryFilter): fix toggle behavior
This commit is contained in:
@@ -5,7 +5,7 @@ import { categoryFilterStore } from '../store/categoryFilterStore';
|
||||
const { categories } = $derived($categoryFilterStore);
|
||||
|
||||
function didCategoryToggle(categoryId: string) {
|
||||
if (categories?.find(category => category.id === categoryId)) {
|
||||
if (categories?.find(category => category.id === categoryId)?.selected) {
|
||||
categoryFilterStore.deselectCategory(categoryId);
|
||||
} else {
|
||||
categoryFilterStore.selectCategory(categoryId);
|
||||
|
||||
@@ -129,7 +129,7 @@ const hasSelection = $derived(selectedCount > 0);
|
||||
<Checkbox
|
||||
id={category.id}
|
||||
checked={category.selected}
|
||||
onchange={() => onCategoryToggle(category.id)}
|
||||
onclick={() => onCategoryToggle(category.id)}
|
||||
class="
|
||||
shrink-0 cursor-pointer transition-all duration-150 ease-out
|
||||
data-[state=checked]:scale-100
|
||||
|
||||
Reference in New Issue
Block a user