mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
Search
This commit is contained in:
@@ -24,14 +24,21 @@ const Searchbar: FC<Props> = ({ className }) => {
|
||||
<input
|
||||
className={s.input}
|
||||
placeholder="Search for products..."
|
||||
defaultValue={router.query.q}
|
||||
onKeyUp={(e) => {
|
||||
e.preventDefault()
|
||||
|
||||
if (e.key === 'Enter') {
|
||||
router.push({
|
||||
pathname: `/search`,
|
||||
query: { q: e.currentTarget.value },
|
||||
})
|
||||
const q = e.currentTarget.value
|
||||
|
||||
router.push(
|
||||
{
|
||||
pathname: `/search`,
|
||||
query: q ? { q } : {},
|
||||
},
|
||||
undefined,
|
||||
{ shallow: true }
|
||||
)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
Reference in New Issue
Block a user