Skip to content

Commit e9f81e4

Browse files
committed
simplify: use plain string[] for useFuzzyFilter keys
The DotPath recursive type is over-engineered for a hook used in 3 places and has edge cases with nullable/union types. Plain string[] is sufficient. https://claude.ai/code/session_01HsDEMADbz1HQmZ4MDD753r
1 parent eb3bed4 commit e9f81e4

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

apps/webapp/app/hooks/useFuzzyFilter.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
import { useMemo, useState } from "react";
22
import { matchSorter } from "match-sorter";
33

4-
type DotPath<T, Depth extends unknown[] = []> = Depth["length"] extends 4
5-
? never
6-
: T extends object
7-
? {
8-
[K in keyof T & string]: K | `${K}.${DotPath<T[K], [...Depth, unknown]>}`;
9-
}[keyof T & string]
10-
: never;
11-
124
/**
135
* A hook that provides fuzzy filtering functionality for a list of objects.
146
* Uses match-sorter to perform the filtering across multiple object properties and
@@ -36,7 +28,7 @@ export function useFuzzyFilter<T extends Object>({
3628
keys,
3729
}: {
3830
items: T[];
39-
keys: DotPath<T>[];
31+
keys: string[];
4032
}) {
4133
const [filterText, setFilterText] = useState("");
4234

0 commit comments

Comments
 (0)