@@ -24,7 +24,7 @@ import { getUrlParam } from 'src/utils/urlUtils';
2424import { Row , Col , Grid } from 'src/components' ;
2525import { MainNav as DropdownMenu , MenuMode } from 'src/components/Menu' ;
2626import { Tooltip } from 'src/components/Tooltip' ;
27- import { Link } from 'react-router-dom' ;
27+ import { Link , useLocation } from 'react-router-dom' ;
2828import { GenericLink } from 'src/components/GenericLink/GenericLink' ;
2929import Icons from 'src/components/Icons' ;
3030import { useUiConfig } from 'src/components/UiConfigContext' ;
@@ -186,6 +186,33 @@ export function Menu({
186186 return ( ) => window . removeEventListener ( 'resize' , windowResize ) ;
187187 } , [ ] ) ;
188188
189+ enum paths {
190+ EXPLORE = '/explore' ,
191+ DASHBOARD = '/dashboard' ,
192+ CHART = '/chart' ,
193+ DATASETS = '/tablemodelview' ,
194+ }
195+
196+ const defaultTabSelection : string [ ] = [ ] ;
197+ const [ activeTabs , setActiveTabs ] = useState ( defaultTabSelection ) ;
198+ const location = useLocation ( ) ;
199+ useEffect ( ( ) => {
200+ const path = location . pathname ;
201+ switch ( true ) {
202+ case path . startsWith ( paths . DASHBOARD ) :
203+ setActiveTabs ( [ 'Dashboards' ] ) ;
204+ break ;
205+ case path . startsWith ( paths . CHART ) || path . startsWith ( paths . EXPLORE ) :
206+ setActiveTabs ( [ 'Charts' ] ) ;
207+ break ;
208+ case path . startsWith ( paths . DATASETS ) :
209+ setActiveTabs ( [ 'Datasets' ] ) ;
210+ break ;
211+ default :
212+ setActiveTabs ( defaultTabSelection ) ;
213+ }
214+ } , [ location . pathname ] ) ;
215+
189216 const standalone = getUrlParam ( URL_PARAMS . standalone ) ;
190217 if ( standalone || uiConfig . hideNav ) return < > </ > ;
191218
@@ -268,6 +295,7 @@ export function Menu({
268295 mode = { showMenu }
269296 data-test = "navbar-top"
270297 className = "main-nav"
298+ selectedKeys = { activeTabs }
271299 >
272300 { menu . map ( ( item , index ) => {
273301 const props = {
0 commit comments