Skip to content

Commit

Permalink
fix: classy react rerender bug and removed console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
levinkerschberger committed Nov 15, 2024
1 parent 7ee0718 commit c423b88
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ export default function ConnectionAttributesFilter<TData>({
sortedUniqueValues,
}: Readonly<ConnectionAttributesFilterProps<TData>>) {
const [open, setOpen] = useState(false);
console.log(sortedUniqueValues);
const [attributes, setAttributes] = useState<Attribute[]>([]);

const handleDeleteAttribute = (targetAttribute: Attribute) => {
console.log(targetAttribute);
setAttributes((prev: Attribute[]) => {
console.log(prev);
return prev.filter(
(prevAttribute) =>
prevAttribute.key != targetAttribute.key &&
Expand All @@ -33,7 +30,6 @@ export default function ConnectionAttributesFilter<TData>({
});

column.setFilterValue((prev: Attribute[]) => {
console.log(prev);
return prev.filter(
(prevAttribute) =>
prevAttribute.key != targetAttribute.key &&
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/ui/filter/ComboFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ export default function ComboFilter<TData, TValue>({
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];
}
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/components/ui/filter/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@ export default function Filter<TData>({
| 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") {
Expand Down

0 comments on commit c423b88

Please sign in to comment.