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:
@@ -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 } },
|
||||
|
||||
Reference in New Issue
Block a user