1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: sidebar update active when navigated via command menu. (#7545)

Currently, if the location changes, it does not update the active item.
I added useEffect to update the active item.

This is required when the user navigates via the command menu.
This commit is contained in:
Jaanus Sellin 2024-07-05 13:28:00 +03:00 committed by GitHub
parent 51a2b3aa0e
commit 165f02a3a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,5 +1,5 @@
import { Box, styled } from '@mui/material';
import { type FC, useState } from 'react';
import { type FC, useState, useEffect } from 'react';
import { useNavigationMode } from './useNavigationMode';
import { ShowAdmin, ShowHide } from './ShowHide';
import { useRoutes } from './useRoutes';
@ -67,6 +67,10 @@ export const NavigationSidebar = () => {
const { lastViewed: lastViewedFlags } = useLastViewedFlags();
const showRecentFlags = mode === 'full' && lastViewedFlags.length > 0;
useEffect(() => {
setActiveItem(initialPathname);
}, [initialPathname]);
return (
<StretchContainer>
<NewInUnleash mode={mode} onMiniModeClick={() => setMode('full')} />