Fixed page reload issue on EnterKey press

This commit is contained in:
monilprajapati
2024-06-17 12:24:32 +05:30
parent e4dd9a53f2
commit 1296af8786
6 changed files with 32 additions and 2 deletions
+2 -2
View File
@@ -88,12 +88,12 @@ const SearchData = props => {
const textFieldRef = useRef(null);
const keyPressHandler = (e) => {
if (e.which === 13) {
if (e.key === "Enter") {
e.preventDefault();
// navigate(`/search?q=${currentRefinement}`, { state: value, replace: true });
// setModalOpen(false);
const trimmedValue = inputValue.trim();
if (trimmedValue !== '') {
e.preventDefault();
navigate(`/search?q=${trimmedValue}`, { state: trimmedValue, replace: true });
setModalOpen(false);
}