Skip to content
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

Menu Items that are part of MenuRadioGroup are not calling the onClick handler on actual Menu #45

Closed
aravindsurya77 opened this issue Feb 3, 2021 · 3 comments

Comments

@aravindsurya77
Copy link

aravindsurya77 commented Feb 3, 2021

Problem Description
I have a functionality that is common for all menu item clicks, so I decided to have that in the onClick handler of the Menu, expecting the menuOnclickHandler would be called for each MenuItem click. But this is not happening if the MenuItem is from a MenuRadioGroup. Also the onClick handler on the RadioMenuItem is not getting called either. Is this intentional? If so what is the reason behind it. Or is this a bug?

CodeSandbox example

https://codesandbox.io/s/serene-minsky-g6xeh?file=/src/App.js

In that example you can notice, that when clicked on the RadioMenuItems, results are not getting updated.

Thanks in advance! :)

@szhsin
Copy link
Owner

szhsin commented Feb 4, 2021

Hi @aravindsurya77 , thanks for your feedback.

React-Menu was originally design to only handle certain events which are necessary for its functionalities. Because the onClick is not required for MenuItems in a radio group, the event is not fired.

Start from v1.1.0, all DOM events are forwarded to the internal DOM element, so it might be necessary add the onClick event in MenuItem to keep the behaviour consistent.

I will consider the impact of this request on the design and backward-compatibility and release a fix in the next version.

@szhsin
Copy link
Owner

szhsin commented Feb 7, 2021

This is released in v1.6.0.
The onClick event will fire on menu items inside a MenuRadioGroup, and then bubble up to the Menu component. The onChange event on MenuRadioGroup still fires as normal.

@szhsin szhsin closed this as completed Feb 7, 2021
@aravindsurya77
Copy link
Author

Thank you so much @szhsin

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

No branches or pull requests

2 participants