Skip to content

Commit

Permalink
do not autofocus search input
Browse files Browse the repository at this point in the history
  • Loading branch information
mruwnik committed Mar 10, 2024
1 parent 3e21e5d commit 10aff05
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions app/components/SearchInput/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useState, useRef, useEffect} from 'react'
import {useState} from 'react'
import MagnifyingIcon from '~/components/icons-generated/Magnifying'
import XIcon from '~/components/icons-generated/X'
import './input.css'
Expand All @@ -19,16 +19,12 @@ interface SearchInputProps {
}
export const SearchInput = ({onChange, expandable, placeholderText}: SearchInputProps) => {
const [search, setSearch] = useState('')
const inputRef = useRef<HTMLInputElement | null>(null)
const handleSearch = (search: string) => {
setSearch(search)
if (onChange) {
onChange(search)
}
}
useEffect(() => {
inputRef.current?.focus()
}, [])
const clear = () => handleSearch('')

return (
Expand All @@ -46,7 +42,6 @@ export const SearchInput = ({onChange, expandable, placeholderText}: SearchInput
handleSearch(e.currentTarget.value)
}}
value={search}
ref={inputRef}
/>
{search !== '' && <XIcon className="x-icon" onClick={clear} />}
</div>
Expand Down

0 comments on commit 10aff05

Please sign in to comment.