fix(explore): Replace url search params only if current page is Explore (#20972)

* fix(explore): Replace url search params only if current page is Explore

* Add unit test
This commit is contained in:
Kamil Gabryjelski
2022-08-05 16:59:52 +02:00
committed by GitHub
parent 499a28f599
commit 9350bbafee
3 changed files with 44 additions and 14 deletions

View File

@@ -206,15 +206,18 @@ const updateHistory = debounce(
);
stateModifier = 'pushState';
}
const url = mountExploreUrl(
standalone ? URL_PARAMS.standalone.name : null,
{
[URL_PARAMS.formDataKey.name]: key,
...additionalParam,
},
force,
);
window.history[stateModifier](payload, title, url);
// avoid race condition in case user changes route before explore updates the url
if (window.location.pathname.startsWith('/explore')) {
const url = mountExploreUrl(
standalone ? URL_PARAMS.standalone.name : null,
{
[URL_PARAMS.formDataKey.name]: key,
...additionalParam,
},
force,
);
window.history[stateModifier](payload, title, url);
}
} catch (e) {
logging.warn('Failed at altering browser history', e);
}