From f753e7260175df1498eb98db626ba4aeebb7d3a6 Mon Sep 17 00:00:00 2001 From: franco sanchez Date: Tue, 3 Oct 2023 12:06:13 -0300 Subject: [PATCH] chore: minor changes in the search input --- src/components/forms/filters/InputSearch.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/forms/filters/InputSearch.tsx b/src/components/forms/filters/InputSearch.tsx index 1c983e3..421f3c6 100644 --- a/src/components/forms/filters/InputSearch.tsx +++ b/src/components/forms/filters/InputSearch.tsx @@ -29,7 +29,7 @@ import { useDebounce } from '../../../hooks/useDebounce'; import { BookSearchResultsType } from '../../../components/types'; function highlightText(text, query) { - const regex = new RegExp(`(${query})`, 'gi'); + const regex = new RegExp(`(${query.trim()})`, 'gi'); return text .split(regex) .map((part, index) => @@ -71,11 +71,11 @@ export function InputSearch({ useOutsideClick({ ref: containerRef, - // handler: () => { - // if (search.query) { - // setSearch({ ...search, query: '' }); - // } - // }, + handler: () => { + if (search.query) { + setSearch({ ...search, query: '' }); + } + }, }); useEffect(() => {