From 05436d3aa37eca78a58b1b7a826d84ea811689de Mon Sep 17 00:00:00 2001 From: Elodie MORIN Date: Wed, 9 Sep 2026 14:01:58 +0200 Subject: [PATCH] fix(frontend): back navigation after coming from annotator --- frontend/src/components/layout/Navigation/Annotator.tsx | 3 ++- .../src/features/Annotator/Navigation/NavigationButtons.tsx | 4 ++-- frontend/src/features/Annotator/Navigation/hooks.ts | 4 ++-- frontend/src/features/Annotator/submit.hook.ts | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/layout/Navigation/Annotator.tsx b/frontend/src/components/layout/Navigation/Annotator.tsx index e76435b36..066bf3788 100644 --- a/frontend/src/components/layout/Navigation/Annotator.tsx +++ b/frontend/src/components/layout/Navigation/Annotator.tsx @@ -38,7 +38,8 @@ export const Annotator: React.FC<{ className?: string, children: ReactNode, load + search={ search } + replace> Back to campaign diff --git a/frontend/src/features/Annotator/Navigation/NavigationButtons.tsx b/frontend/src/features/Annotator/Navigation/NavigationButtons.tsx index 1eb9baf92..0dee2c9d5 100644 --- a/frontend/src/features/Annotator/Navigation/NavigationButtons.tsx +++ b/frontend/src/features/Annotator/Navigation/NavigationButtons.tsx @@ -25,12 +25,12 @@ export const NavigationButtons: React.FC = () => { const navPrevious = useCallback(async () => { if (isPending) return; if (!info?.previousSpectrogramId) return; - if (await canNavigate()) openAnnotator(info.previousSpectrogramId, { replace: true }) + if (await canNavigate()) openAnnotator(info.previousSpectrogramId) }, [ openAnnotator, isPending, info, canNavigate ]) const navNext = useCallback(async () => { if (isPending) return; if (!info?.nextSpectrogramId) return; - if (await canNavigate()) openAnnotator(info.nextSpectrogramId, { replace: true }) + if (await canNavigate()) openAnnotator(info.nextSpectrogramId) }, [ canNavigate, openAnnotator, isPending, info ]) useHotkey('ArrowLeft', navPrevious) diff --git a/frontend/src/features/Annotator/Navigation/hooks.ts b/frontend/src/features/Annotator/Navigation/hooks.ts index 498664b7d..648995bab 100644 --- a/frontend/src/features/Annotator/Navigation/hooks.ts +++ b/frontend/src/features/Annotator/Navigation/hooks.ts @@ -30,14 +30,14 @@ export const useOpenAnnotator = () => { const search: any = useSearch({ strict: false }); const navigate = useNavigate() - return useCallback((spectrogramID: string, options?: { resume?: boolean, replace?: boolean }) => { + return useCallback((spectrogramID: string, options?: { resume?: boolean }) => { const _search = { ...search } if (options?.resume) _search.onlyAssigned = true navigate({ to: '/annotation-campaign/$campaignID/phase/$phaseType/spectrogram/$spectrogramID', params: { ...routeParams, spectrogramID }, search: _search, - replace: options?.replace, + replace: true, }); }, [ routeParams, search, navigate ]) } \ No newline at end of file diff --git a/frontend/src/features/Annotator/submit.hook.ts b/frontend/src/features/Annotator/submit.hook.ts index bb8ffad1f..2cd5ccd94 100644 --- a/frontend/src/features/Annotator/submit.hook.ts +++ b/frontend/src/features/Annotator/submit.hook.ts @@ -73,11 +73,11 @@ export const useAnnotatorSubmit = () => { useEffect(() => { if (!isSuccess) return; if (info?.nextSpectrogramId) { - openAnnotator(info.nextSpectrogramId, { replace: true }); + openAnnotator(info.nextSpectrogramId); } else { navigate({ to: '/annotation-campaign/$campaignID/phase/$phaseType', - params, search, + params, search, replace: true }) } }, [ isSuccess, navigate ]);