mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
useBasicSearch: stricter search criteria
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useState } from "react";
|
||||
import { useDebouncedCallback } from "use-debounce";
|
||||
import { matchSorter } from "match-sorter";
|
||||
import { matchSorter, rankings } from "match-sorter";
|
||||
|
||||
export function useBasicSearch<T>(
|
||||
list: T[],
|
||||
@@ -10,7 +10,9 @@ export function useBasicSearch<T>(
|
||||
const [query, setQuery] = useState("");
|
||||
const handleQuery = useDebouncedCallback(setQuery, debounce);
|
||||
|
||||
const results = query ? matchSorter(list, query, { keys }) : list;
|
||||
const results = query
|
||||
? matchSorter(list, query, { keys, threshold: rankings.ACRONYM })
|
||||
: list;
|
||||
|
||||
return [results, query, handleQuery] as const;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ import { useScrollToHash } from "@src/hooks/useScrollToHash";
|
||||
|
||||
const SEARCH_KEYS = ["id", "name", "section", "description"];
|
||||
|
||||
export default function HomePage() {
|
||||
export default function TablesPage() {
|
||||
const [userRoles] = useAtom(userRolesAtom, projectScope);
|
||||
const [userSettings] = useAtom(userSettingsAtom, projectScope);
|
||||
const [updateUserSettings] = useAtom(updateUserSettingsAtom, projectScope);
|
||||
|
||||
Reference in New Issue
Block a user