Skip to content

Commit

Permalink
JNG-6181 fix create and open navigation (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg authored Feb 19, 2025
1 parent 1be9c25 commit 1f044e6
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ export const useJudoNavigation = () => {
return context;
};

const delayed = (fn: () => void, delay = 0) => {
// At the time of writing there are certain cases where navigation is ignored by the router. Such as after closing certain
// dialogs until we figure out why this is a delay solves the navigation issue.
window.setTimeout(fn, delay);
};

export const BreadcrumbProvider = ({ children }: BreadcrumbProviderProps) => {
const navigate = useNavigate();
const location = useLocation();
Expand Down Expand Up @@ -103,7 +109,7 @@ export const BreadcrumbProvider = ({ children }: BreadcrumbProviderProps) => {
});

if (triggerNavigation) {
navigate(decorator(lastItem.path));
delayed(() => navigate(decorator(lastItem.path)));
}
} else {
setBreadcrumbItems([]);
Expand All @@ -113,7 +119,7 @@ export const BreadcrumbProvider = ({ children }: BreadcrumbProviderProps) => {
});

if (triggerNavigation) {
navigate(decorator(routeToDashboard()));
delayed(() => navigate(decorator(routeToDashboard())));
}
}
}, [breadcrumbItems, nextBreadcrumbItem]);
Expand All @@ -129,7 +135,7 @@ export const BreadcrumbProvider = ({ children }: BreadcrumbProviderProps) => {
path: to,
});

navigate(decorator(to));
delayed(() => navigate(decorator(to)));
},
navigateBackTo: (item: BreadcrumbItem) => {
const idx = breadcrumbItems.indexOf(item);
Expand All @@ -140,7 +146,7 @@ export const BreadcrumbProvider = ({ children }: BreadcrumbProviderProps) => {
path: item.path,
});

navigate(decorator(item.path));
delayed(() => navigate(decorator(item.path)));
}
},
navigate: (to: To) => {
Expand All @@ -154,7 +160,7 @@ export const BreadcrumbProvider = ({ children }: BreadcrumbProviderProps) => {
path: to,
});

navigate(decorator(to));
delayed(() => navigate(decorator(to)));
},
back: () => {
breadCrumbBack(true);
Expand Down

0 comments on commit 1f044e6

Please sign in to comment.