Skip to content

Commit

Permalink
Putting an X for clearing of entry in EVERY search bar field
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel21Monacillo committed Nov 21, 2024
1 parent 5e386a4 commit 3467fbc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion client/src/components/molecules/GlobalSearchFilter/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from 'classnames'
import { Search } from 'react-feather'
import { Search, X } from 'react-feather'
import React, { FC, InputHTMLAttributes, useEffect, useState } from 'react'

type Props = {
Expand All @@ -26,6 +26,11 @@ const GlobalSearchFilter: FC<Props> = (props): JSX.Element => {
return () => clearTimeout(timeout)
}, [value])

const handleClear = () => {

Check failure on line 29 in client/src/components/molecules/GlobalSearchFilter/index.tsx

View workflow job for this annotation

GitHub Actions / Build frontend

Missing return type on function
setValue('')
onChange('') // Notify parent to clear search results
}

return (
<div className={classNames('group flex items-center space-x-2', className)}>
<Search className="h-5 w-5 text-slate-400 group-focus-within:text-amber-500" />
Expand All @@ -41,6 +46,15 @@ const GlobalSearchFilter: FC<Props> = (props): JSX.Element => {
onChange={(e) => setValue(e.target.value)}
placeholder="Search"
/>

<button
type="button"
className="flex h-5 w-5 items-center justify-center text-slate-400 focus:outline-none hover:text-amber-500"
onClick={handleClear}
aria-label="Clear search"
>
<X className="h-5 w-5" />
</button>
</div>
)
}
Expand Down

0 comments on commit 3467fbc

Please sign in to comment.