mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-06 01:15:28 +02: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:
parent
51a2b3aa0e
commit
165f02a3a4
@ -1,5 +1,5 @@
|
|||||||
import { Box, styled } from '@mui/material';
|
import { Box, styled } from '@mui/material';
|
||||||
import { type FC, useState } from 'react';
|
import { type FC, useState, useEffect } from 'react';
|
||||||
import { useNavigationMode } from './useNavigationMode';
|
import { useNavigationMode } from './useNavigationMode';
|
||||||
import { ShowAdmin, ShowHide } from './ShowHide';
|
import { ShowAdmin, ShowHide } from './ShowHide';
|
||||||
import { useRoutes } from './useRoutes';
|
import { useRoutes } from './useRoutes';
|
||||||
@ -67,6 +67,10 @@ export const NavigationSidebar = () => {
|
|||||||
const { lastViewed: lastViewedFlags } = useLastViewedFlags();
|
const { lastViewed: lastViewedFlags } = useLastViewedFlags();
|
||||||
const showRecentFlags = mode === 'full' && lastViewedFlags.length > 0;
|
const showRecentFlags = mode === 'full' && lastViewedFlags.length > 0;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setActiveItem(initialPathname);
|
||||||
|
}, [initialPathname]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StretchContainer>
|
<StretchContainer>
|
||||||
<NewInUnleash mode={mode} onMiniModeClick={() => setMode('full')} />
|
<NewInUnleash mode={mode} onMiniModeClick={() => setMode('full')} />
|
||||||
|
Loading…
Reference in New Issue
Block a user