Skip to content

Commit

Permalink
fix: set activeKey with navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Oct 16, 2024
1 parent ded2f07 commit a31836e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/library-authoring/LibraryAuthoringPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | undefined>('');

useEffect(() => {
const currentPath = location.pathname.split('/').pop();

const [activeKey, setActiveKey] = useState<string | undefined>(initialActiveKey);
if (componentPickerMode || currentPath === libraryId || currentPath === '') {
setActiveKey(TabList.home);
} else if (currentPath && currentPath in TabList) {
setActiveKey(TabList[currentPath]);
}
}, [location.pathname]);

useEffect(() => {
if (!componentPickerMode) {
Expand Down

0 comments on commit a31836e

Please sign in to comment.