From d83b1b69ca6e9078e16a4b0e40a93b41b0d70746 Mon Sep 17 00:00:00 2001
From: Lorenzo Corallo <66379281+lorenzocorallo@users.noreply.github.com>
Date: Thu, 22 Aug 2024 17:03:56 +0200
Subject: [PATCH 1/4] feat: add version in about page (#256)
---
src/routes/about/index.tsx | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/routes/about/index.tsx b/src/routes/about/index.tsx
index a1a4b7c6..dc2910ec 100644
--- a/src/routes/about/index.tsx
+++ b/src/routes/about/index.tsx
@@ -62,16 +62,19 @@ export const aboutRoute = new Route({
-
From cdf9bb15e94179ebca77f56c10cdfb62e4aee122 Mon Sep 17 00:00:00 2001
From: Lorenzo Corallo <66379281+lorenzocorallo@users.noreply.github.com>
Date: Thu, 22 Aug 2024 17:05:13 +0200
Subject: [PATCH 2/4] feat: close filter popover when clearing it (#257)
Co-authored-by: angeousta <132761637+angeousta@users.noreply.github.com>
---
src/routes/viewer/Table/FilterBtn.tsx | 38 ++++++++++++++++-----------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/src/routes/viewer/Table/FilterBtn.tsx b/src/routes/viewer/Table/FilterBtn.tsx
index 3466db22..f44dc8a4 100644
--- a/src/routes/viewer/Table/FilterBtn.tsx
+++ b/src/routes/viewer/Table/FilterBtn.tsx
@@ -19,6 +19,7 @@ import {
PopoverTrigger,
} from "@/components/ui/popover";
import { Separator } from "@/components/ui/separator";
+import { useState } from "react";
export type FilterOption = {
originalValue: T;
@@ -38,11 +39,29 @@ export function FilterBtn({
title,
options,
}: Props) {
+ const [open, setOpen] = useState(false);
const facets = column.getFacetedUniqueValues();
const selectedValues = new Set(column?.getFilterValue() as string[]);
+ function handleClearFilter(): void {
+ column?.setFilterValue(undefined);
+ setOpen(false);
+ }
+
+ function handleOptionSelect(
+ option: FilterOption,
+ isSelected: boolean,
+ ): void {
+ if (options.length <= 2) selectedValues.clear(); // filter with radio behaviour
+ if (isSelected) selectedValues.delete(option.value); // toggle behaviour
+ else selectedValues.add(option.value);
+
+ const filterValues = Array.from(selectedValues); // get selected filter options
+ column?.setFilterValue(filterValues.length ? filterValues : undefined); // update table
+ }
+
return (
-
+