Skip to content

Navigate to route on AppSideBarNav parent menu click. #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
regimani opened this issue Jan 16, 2020 · 1 comment · Fixed by #104
Closed

Navigate to route on AppSideBarNav parent menu click. #98

regimani opened this issue Jan 16, 2020 · 1 comment · Fixed by #104

Comments

@regimani
Copy link

Currently when user click on the parent menu item, it just toggle and display/hide the child menu items. The href is being hard coded to # for the dropdown component. Is there a way to set a url for the parent dropdown menu item?

@xidedix
Copy link
Member

xidedix commented Feb 26, 2020

@regimani
To override the default behavior of nav-dropdown toggle and navigate to url use custom onClick method:

{
  name: 'Base',
  url: '/base',
  icon: 'icon-puzzle',
  attributes: {onClick: (e, item)=>{ console.log(e, item) }}, // (v2.5.6 up) optional
  children: [
    ...
  ]
}

For active route consistency, you can set redirect on partial routes in src/routes.js:

import { Redirect } from 'react-router-dom';
...
const routes = [
  ...
  { path: '/base', exact: true, name: 'Base', component: () => <Redirect to={'/base/cards'}/> },
  { path: '/base/cards', name: 'Cards', component: Cards },
  { path: '/base/forms', name: 'Forms', component: Forms },
  ...
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants