diff --git a/src/library-authoring/LibraryAuthoringPage.tsx b/src/library-authoring/LibraryAuthoringPage.tsx index 538d6f7653..786c976196 100644 --- a/src/library-authoring/LibraryAuthoringPage.tsx +++ b/src/library-authoring/LibraryAuthoringPage.tsx @@ -152,15 +152,17 @@ const LibraryAuthoringPage = ({ returnToLibrarySelection }: LibraryAuthoringPage openInfoSidebar, } = useLibraryContext(); - const currentPath = location.pathname.split('/').pop(); - let initialActiveKey: string | undefined; - if (componentPickerMode || currentPath === libraryId || currentPath === '') { - initialActiveKey = TabList.home; - } else if (currentPath && currentPath in TabList) { - initialActiveKey = TabList[currentPath]; - } + const [activeKey, setActiveKey] = useState(''); + + useEffect(() => { + const currentPath = location.pathname.split('/').pop(); - const [activeKey, setActiveKey] = useState(initialActiveKey); + if (componentPickerMode || currentPath === libraryId || currentPath === '') { + setActiveKey(TabList.home); + } else if (currentPath && currentPath in TabList) { + setActiveKey(TabList[currentPath]); + } + }, [location.pathname]); useEffect(() => { if (!componentPickerMode) {