question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Menu.Item should have the onClick param

See original GitHub issue

What problem does this feature solve?

I’d like to have a dropdown where one of the buttons is the logout button. When having a dropdown you can use MenuItemGroup and then populate it with X numbers of Menu.Item. At the moment Menu.Item doesn’t support the onClick param so I can’t attach a function to it. And I can’t just add a Button component inside of MenuItemGroup because it will cause a lot of errors.

If Menu.Item supported the onClick param the development would be must easier and the design would stay consistent.

You could ofc add the onClick on the Menu and then write something like:

const onClick = ({ key }) => {
  // Use the key here
  // If you want to use a specific key you have to do something like:
  if (key === 'valueOfTheKey') {
    console.log('something')
  }
}

But why do that?

What does the proposed API look like?

Add the onClick param to Menu.Item. It would make things a lot easier.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:47
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

37reactions
ddcat1115commented, Jan 18, 2018

Menu onClick can meet your needs

21reactions
channprjcommented, Apr 12, 2018

NOTE: Please click the thumb up (👍) rather than ‘+1’ comment.

<Menu.Item key='activate'>
  <a onClick={(event) => this.props.hadleActivate(event, this.props.index, !this.props.activate)}>
    { !this.props.activate ? 'Activate' : 'Deactivate' }
  </a>
</Menu.Item>

Wrapping with <a> works fine, but I think this way doesn’t look nice. Need your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Material-UI MenuItem automatically sends argument to ...
Material-UI passes the DOM event as an argument on the onClick. ... The outer function will get called at the time of rendering....
Read more >
ProfileMenuItem has no Click parameter while MenuItem does?
No sure why this is, but the behavior for a menu item and profile menu item differ when it comes to handling or...
Read more >
class Menu
The onClick for the menu item will be called instead. Therefore, if you have a menu item for Help it should not have...
Read more >
Class Ext.menu.Item - UNODC
A base class for all menu items that require menu-related functionality (like sub-menus) and are not static display items. Item extends the base ......
Read more >
Menus - Android Developers
The options menu is the primary collection of menu items for an activity. It's where you should place actions that have a global...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found