From 190a94f96eeabaf5bfd50245b0ae880854ecbc78 Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Fri, 22 Nov 2024 17:47:25 +0100 Subject: [PATCH] Fixed category filter functions --- components/calendar/search/CalendarSearch.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/components/calendar/search/CalendarSearch.vue b/components/calendar/search/CalendarSearch.vue index 26682cf..25f3376 100644 --- a/components/calendar/search/CalendarSearch.vue +++ b/components/calendar/search/CalendarSearch.vue @@ -212,11 +212,21 @@ const categoryFilterOpened = ref(false) const searchCategory = ref("") const filteredCategories = computed(() => { + // Display original data if (!currentCategories.value) return [] - return currentCategories.value.filter((i) => !selectedCategories.value.includes(i)) + + // If current categories are selected, ignore them + if (!searchCategory.value) return currentCategories.value.filter((i) => !selectedCategories.value.includes(i)) + + // If we also have a query to filter them by, do that + return currentCategories.value.filter((i) => { + return !selectedCategories.value.includes(i) && i.name.toLocaleLowerCase().includes(searchCategory.value.toLocaleLowerCase()) + }) }) +// Reactivity rules for category searches const categoryInput = ref(null) +const categoryInputValue = ref("") const { focused: categoryInputFocused } = useFocus(categoryInput) watch(categoryInputFocused, (isFocused) => { @@ -318,6 +328,7 @@ function handleCategoryUnselect(e: Category) {