-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Issue with props merging on Menu #1424
Comments
This is not a factory bug but the menu is incorrectly handling the items. First, when creating shorthand items, the menu passes default props as an object. This means the items' onClick handler will override the default prop onClick handler:
The menu should use the callback form of defaultProps which receives the user's props as an argument. This way, the onClick handler can wrap the user's onClick handler as well. Second, the handleItemClick method assumes the items to be an array of objects from which it tries to lookup the clicked index and call the item's onClick handler. Instead, we should leave this to the wrapped item handler. I'm not sure that we should auto wrap handlers in the factories as there may be cases where we want the override behavior. |
I'll make PR that updates tests and Menu items handling. |
I may have spoken prematurely on this as well. It will take more effort to diagnose properly. The defaultProps I believe are always overriden by the user's props. It is possible that even wrapping the user's props in the default props will be of no use as the user's handler will override the wrapped default handler: https://github.com/Semantic-Org/Semantic-UI-React/blob/master/src/lib/factories.js#L46 const props = { ...defaultProps, ...usersProps } Seems we need a way to define not |
It was fixed in #1428 ✌️ |
Extracted from #1375.
Steps
Expected Result
Call of
handleItem
andhandleMenu
on click onMenuItem
.Actual Result
Only
handleItem
was called.In fact, we don't call
handleItemClick
whenonClick
was passed to anMenuItem
.Version
Latest.
Testcase
http://codepen.io/layershifter/pen/aJBmwz
The text was updated successfully, but these errors were encountered: