From df5ae77ad51996cd0317352b1fde5c38a2e86c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Katharina=20W=C3=BCnsche?= Date: Tue, 5 Nov 2024 11:05:08 +0100 Subject: [PATCH] chore: reset facet selection when column is hidden --- components/data-table/data-table-filter-columns.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/data-table/data-table-filter-columns.vue b/components/data-table/data-table-filter-columns.vue index 53428ed..239dbc5 100644 --- a/components/data-table/data-table-filter-columns.vue +++ b/components/data-table/data-table-filter-columns.vue @@ -35,7 +35,10 @@ function toggleCategory(category: Column) { default: targetVisibility = true; } - category.columns.forEach((c) => c.toggleVisibility(targetVisibility)); + category.columns.forEach((c) => { + c.toggleVisibility(targetVisibility); + if (!targetVisibility) c.setFilterValue([]); + }); } const isCollapsibleOpen = ref(columns.value.map(() => false)); @@ -77,7 +80,12 @@ const visibilityToIcon: Record = { :key="column.id" :checked="column.getIsVisible()" @select.prevent - @update:checked="(value) => column.toggleVisibility(!!value)" + @update:checked=" + (value) => { + column.toggleVisibility(!!value); + column.setFilterValue([]); + } + " > {{ column.columnDef.header }}