mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
fix: replace history entries when searching (#62)
This commit is contained in:
@@ -63,9 +63,9 @@ export default function SearchBar({ searchList }: Props) {
|
|||||||
searchParams.set("q", inputVal);
|
searchParams.set("q", inputVal);
|
||||||
const newRelativePathQuery =
|
const newRelativePathQuery =
|
||||||
window.location.pathname + "?" + searchParams.toString();
|
window.location.pathname + "?" + searchParams.toString();
|
||||||
history.pushState(null, "", newRelativePathQuery);
|
history.replaceState(null, "", newRelativePathQuery);
|
||||||
} else {
|
} else {
|
||||||
history.pushState(null, "", window.location.pathname);
|
history.replaceState(null, "", window.location.pathname);
|
||||||
}
|
}
|
||||||
}, [inputVal]);
|
}, [inputVal]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user