Menu.Item should have the onClick param
See original GitHub issueWhat 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:
- Created 6 years ago
- Reactions:47
- Comments:15 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Menu
onClick
can meet your needsWrapping with
<a>
works fine, but I think this way doesn’t look nice. Need your help!