Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/components/databrowser/components/sidebar/search-input.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useState } from "react"
import { useDatabrowserStore } from "@/store"
import { IconX } from "@tabler/icons-react"

Expand All @@ -6,14 +7,27 @@ import { Input } from "@/components/ui/input"

export const SearchInput = () => {
const { setSearchKey, search } = useDatabrowserStore()
const [state, setState] = useState(search.key)

const submit = (value: string) => {
if (value.trim() !== "" && !value.includes("*")) value = `${value}*`
setSearchKey(value)
setState(value)
}

return (
<div className="relative grow">
<Input
placeholder="Search"
className={"rounded-l-none border-zinc-300 font-normal"}
onChange={(e) => setSearchKey(e.target.value)}
value={search.key}
onKeyDown={(e) => {
if (e.key === "Enter") submit(e.currentTarget.value)
}}
onChange={(e) => {
setState(e.currentTarget.value)
if (e.currentTarget.value.trim() === "") submit("")
}}
value={state}
/>
{search.key && (
<Button
Expand Down
10 changes: 1 addition & 9 deletions src/components/databrowser/hooks/use-keys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,7 @@ const KeysContext = createContext<
export const FETCH_KEYS_QUERY_KEY = "use-fetch-keys"

export const KeysProvider = ({ children }: PropsWithChildren) => {
const { search: searchState } = useDatabrowserStore()

const search = useMemo(
() => ({
key: searchState.key.includes("*") ? searchState.key : `*${searchState.key}*`,
type: searchState.type,
}),
[searchState]
)
const { search } = useDatabrowserStore()

const { fetchKeys, resetCache } = useFetchKeys(search)
const pageRef = useRef(0)
Expand Down
Loading