Skip to content

Commit ebbe4ad

Browse files
committed
feat: Only search at the beginning of words when searching hierarchy in filter
1 parent e674174 commit ebbe4ad

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

app/components/select-tree.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,12 @@ export type SelectTreeProps = {
273273
};
274274

275275
const getFilteredOptions = (options: Tree, value: string) => {
276+
const rx = new RegExp(`^${value}|\\s${value}`, "i");
276277
return value === ""
277278
? options
278-
: (pruneTree(options as HierarchyValue[], (d) =>
279-
d.label.toLowerCase().includes(value.toLowerCase())
279+
: (pruneTree(
280+
options as HierarchyValue[],
281+
(d) => !!d.label.match(rx)
280282
) as Tree);
281283
};
282284

0 commit comments

Comments
 (0)