Skip to content

Commit

Permalink
feat: Add replace option when setting default params
Browse files Browse the repository at this point in the history
This ensures the default value is set without creating a new history entry, improving navigation behavior.
  • Loading branch information
anshg1214 committed Oct 20, 2024
1 parent 7fc4fd1 commit bf40599
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion frontend/js/src/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export default function Search() {

React.useEffect(() => {
if (invalidSearchTypes(searchType)) {
setSearchParams({ search_term: searchTerm, search_type: "artist" });
setSearchParams(
{ search_term: searchTerm, search_type: "artist" },
{ replace: true }
);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [searchType]);
Expand Down
2 changes: 1 addition & 1 deletion frontend/js/src/user/stats/UserReports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function UserReports() {

React.useEffect(() => {
if (!range || isInvalidStatRange(range)) {
setSearchParams({ range: "week" });
setSearchParams({ range: "week" }, { replace: true });
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [range]);
Expand Down

0 comments on commit bf40599

Please sign in to comment.