Prevent navigation state update in case path already changed (#511)

The fix of e4beafb11f only worked in dev env and not in prod.
This prevents the navigation state update from getting triggered in case the path has changed in the meantime
This commit is contained in:
schroda
2023-12-24 02:36:09 +01:00
committed by GitHub
parent e4beafb11f
commit 09d1cf91e0

View File

@@ -95,8 +95,15 @@ const VerticalGrid = ({
const persistGridStateTimeout = useRef<NodeJS.Timeout | undefined>();
const persistGridState = (gridState: GridStateSnapshot) => {
const currentUrl = window.location.href;
clearTimeout(persistGridStateTimeout.current);
persistGridStateTimeout.current = setTimeout(() => {
const didLocationChange = currentUrl !== window.location.href;
if (didLocationChange) {
return;
}
navigate(
{ pathname: '', search: location.search },
{ replace: true, state: { ...location.state, snapshot: gridState } },