diff --git a/src/layouts/helpers/SearchModal.tsx b/src/layouts/helpers/SearchModal.tsx index 142f242..2ae0d01 100644 --- a/src/layouts/helpers/SearchModal.tsx +++ b/src/layouts/helpers/SearchModal.tsx @@ -8,35 +8,9 @@ const SearchModal = () => { // handle input change const handleSearch = (e: React.FormEvent) => { - setSearchString(e.currentTarget.value.toLowerCase()); + setSearchString(e.currentTarget.value.replace("\\", "").toLowerCase()); }; - // set input value from url - useEffect(() => { - const searchUrl = new URLSearchParams(window.location.search); - const searchStr = searchUrl.get("q"); - searchStr && setSearchString(searchStr.toLowerCase()); - - // set cursor position - setTimeout(function () { - searchInputRef.current!.selectionStart = - searchInputRef.current!.selectionEnd = searchStr?.length || 0; - }, 50); - }, []); - - // update url - useEffect(() => { - if (searchString.length > 0) { - const searchParams = new URLSearchParams(window.location.search); - searchParams.set("s", searchString); - const newRelativePathQuery = - window.location.pathname + "?" + searchParams.toString(); - history.pushState(null, "", newRelativePathQuery); - } else { - history.pushState(null, "", window.location.pathname); - } - }, [searchString]); - // generate search result const doSearch = (searchData: ISearchItem[]) => { const regex = new RegExp(`${searchString}`, "gi");