Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/components/manage/Blocks/FiltersMap/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,21 @@ const View = ({
updateOptions();
}, [updateOptions]);

//Remove query params from URL on other pages
//Reset query state and clean URL when component unmounts
useEffect(() => {
const explorePath = location.pathname;
return () => {
const isOnExplorePage = location.pathname.includes('/explore');
if (!isOnExplorePage) {
dispatch(resetQuery());
setFiltersInitialized(false);
history.replace({ pathname: location.pathname });
}
dispatch(resetQuery());
setFiltersInitialized(false);
// Clean URL params when leaving the page
setTimeout(() => {
if (!window.location.pathname.includes(explorePath)) {
const cleanUrl = window.location.pathname;
window.history.replaceState({}, '', cleanUrl);
}
}, 0);
};
}, []);
}, [dispatch, location.pathname]);

return (
<div className="filters-block outline-button">
Expand Down