empty search handled

This commit is contained in:
VividTruthKeeper 2023-03-03 15:02:06 +05:00
parent 8002c195e1
commit 83ec548da0
1 changed files with 7 additions and 1 deletions

View File

@ -28,6 +28,10 @@ const Search = ({ isSmall, isInputFocused, setIsInputFocused }: IProps) => {
dispatch(setSearch(value)); dispatch(setSearch(value));
}; };
const searchValue = useSelector<RootState, RootState["search"]["value"]>(
(state) => state.search.value
);
// redux // redux
const dispatch = useDispatch(); const dispatch = useDispatch();
const inputValue = useSelector<RootState, RootState["search"]["value"]>( const inputValue = useSelector<RootState, RootState["search"]["value"]>(
@ -44,7 +48,9 @@ const Search = ({ isSmall, isInputFocused, setIsInputFocused }: IProps) => {
className="search" className="search"
onSubmit={(event: React.FormEvent<HTMLFormElement>) => { onSubmit={(event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault(); event.preventDefault();
navigate(`/search/${inputValue}`); if (searchValue.length > 0) {
navigate(`/search/${inputValue}`);
}
}} }}
variants={searchMobileMotion} variants={searchMobileMotion}
initial={isSmall ? "borderRest" : {}} initial={isSmall ? "borderRest" : {}}