From c423b887aed8b44989a1f658157f4cf85dabf841 Mon Sep 17 00:00:00 2001 From: Levin Kerschberger Date: Fri, 15 Nov 2024 18:56:28 +0100 Subject: [PATCH] fix: classy react rerender bug and removed console logs --- .../connections/filter/ConnectionAttributesFilter.tsx | 4 ---- frontend/src/components/ui/filter/ComboFilter.tsx | 2 -- frontend/src/components/ui/filter/Filter.tsx | 10 +++++++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/features/connections/filter/ConnectionAttributesFilter.tsx b/frontend/src/components/features/connections/filter/ConnectionAttributesFilter.tsx index 7d768f13..ef9705fb 100644 --- a/frontend/src/components/features/connections/filter/ConnectionAttributesFilter.tsx +++ b/frontend/src/components/features/connections/filter/ConnectionAttributesFilter.tsx @@ -18,13 +18,10 @@ export default function ConnectionAttributesFilter({ sortedUniqueValues, }: Readonly>) { const [open, setOpen] = useState(false); - console.log(sortedUniqueValues); const [attributes, setAttributes] = useState([]); const handleDeleteAttribute = (targetAttribute: Attribute) => { - console.log(targetAttribute); setAttributes((prev: Attribute[]) => { - console.log(prev); return prev.filter( (prevAttribute) => prevAttribute.key != targetAttribute.key && @@ -33,7 +30,6 @@ export default function ConnectionAttributesFilter({ }); column.setFilterValue((prev: Attribute[]) => { - console.log(prev); return prev.filter( (prevAttribute) => prevAttribute.key != targetAttribute.key && diff --git a/frontend/src/components/ui/filter/ComboFilter.tsx b/frontend/src/components/ui/filter/ComboFilter.tsx index f581c63b..491c936e 100644 --- a/frontend/src/components/ui/filter/ComboFilter.tsx +++ b/frontend/src/components/ui/filter/ComboFilter.tsx @@ -35,10 +35,8 @@ export default function ComboFilter({ const index = old.indexOf(value); if (index > -1) { // Remove the value from the array - console.log("Remove!"); return old.filter((item) => item !== value); } else { - console.log("add!"); // Add the value to the array return [...old, value]; } diff --git a/frontend/src/components/ui/filter/Filter.tsx b/frontend/src/components/ui/filter/Filter.tsx index 50b0b9ae..f456039e 100644 --- a/frontend/src/components/ui/filter/Filter.tsx +++ b/frontend/src/components/ui/filter/Filter.tsx @@ -17,21 +17,25 @@ export default function Filter({ | string | undefined; + const facetedUniqueValues = column.getFacetedUniqueValues(); + const getSortedUniqueValues = (): string[] => { // Not implemented yet! if (filterVariant === "range") { return []; - } else { - const values = Array.from(column.getFacetedUniqueValues().keys()) + } else if (filterVariant === "search" || filterVariant === "select") { + const values = Array.from(facetedUniqueValues.keys()) .sort((a: string, b: string) => a.localeCompare(b)) .slice(0, 5000); return values as string[]; + } else { + return Array.from(facetedUniqueValues.keys()) as string[]; } }; const sortedUniqueValues = useMemo(getSortedUniqueValues, [ filterVariant, - column, + facetedUniqueValues, ]); if (filterVariant === "range") {