diff --git a/src/library-authoring/LibraryLayout.tsx b/src/library-authoring/LibraryLayout.tsx index c093af7ad..728d31cab 100644 --- a/src/library-authoring/LibraryLayout.tsx +++ b/src/library-authoring/LibraryLayout.tsx @@ -3,7 +3,6 @@ import { Route, Routes, useParams, - useLocation, } from 'react-router-dom'; import { ROUTES } from './routes'; @@ -23,12 +22,8 @@ const LibraryLayout = () => { throw new Error('Error: route is missing libraryId.'); } - const location = useLocation(); const context = useCallback((childPage) => ( { - ), [location.pathname]); + ), []); return ( diff --git a/src/library-authoring/collections/CollectionInfo.tsx b/src/library-authoring/collections/CollectionInfo.tsx index 277a6fc1c..25af48fd9 100644 --- a/src/library-authoring/collections/CollectionInfo.tsx +++ b/src/library-authoring/collections/CollectionInfo.tsx @@ -6,6 +6,7 @@ import { Tabs, } from '@openedx/paragon'; import { useCallback } from 'react'; +import { useNavigate } from 'react-router-dom'; import { useComponentPickerContext } from '../common/context/ComponentPickerContext'; import { useLibraryContext } from '../common/context/LibraryContext'; @@ -24,6 +25,7 @@ import messages from './messages'; const CollectionInfo = () => { const intl = useIntl(); + const navigate = useNavigate(); const { componentPickerMode } = useComponentPickerContext(); const { libraryId, setCollectionId } = useLibraryContext(); @@ -48,7 +50,7 @@ const CollectionInfo = () => { if (componentPickerMode) { setCollectionId(collectionId); } else { - navigateTo({ collectionId }); + navigate(`/library/${libraryId}/collection/${collectionId}`); } }, [componentPickerMode, navigateTo]); diff --git a/src/library-authoring/routes.ts b/src/library-authoring/routes.ts index fa96c7be0..59811aaab 100644 --- a/src/library-authoring/routes.ts +++ b/src/library-authoring/routes.ts @@ -82,13 +82,7 @@ export const useLibraryRoutes = (): LibraryRoutesData => { route = ROUTES.HOME; } else if (insideCollections) { // We're inside the Collections tab, - route = ( - (collectionId && collectionId === params.collectionId) - // now open the previously-selected collection, - ? ROUTES.COLLECTION - // or stay there to list all collections, or a selected collection. - : ROUTES.COLLECTIONS - ); + route = ROUTES.COLLECTIONS; } else if (insideCollection) { // We're viewing a Collection, so stay there, // and optionally select a component in that collection. @@ -103,13 +97,7 @@ export const useLibraryRoutes = (): LibraryRoutesData => { route = ROUTES.COMPONENT; } else { // We're inside the All Content tab, - route = ( - (collectionId && collectionId === params.collectionId) - // now open the previously-selected collection - ? ROUTES.COLLECTION - // or stay there to list all content, or optionally select a collection. - : ROUTES.HOME - ); + route = ROUTES.HOME; } const newPath = generatePath(BASE_ROUTE + route, routeParams);