react-contexify
react-contexify copied to clipboard
Props not passed when Items inside intermediary component
Hi! While running similar code to the following, I find that, when Item is placed inside a fragment, or inside of another component that goes into Menu, the click event received by the handler is undefined, and the props aren't passed on.
<Menu>
<Item onClick={onMenuItemClick}>Item 1</Item>
{asd === dsa && (
<>
<Item onClick={onMenuItemClick}>Item 2</Item>
<Item onClick={onMenuItemClick}>Item 3</Item>
</>
)}
</Menu>
Happens to me to. Something broke in the latest versions - it used to works. It seems the when Item is created, for the inner items, props.propsFromTrigger isn't passed.
When investigating more, it may be due to cloneItem doing React.cloneElement to theitem - it does a shallow clone, and so the object propsFromTrigger isn't cloned.
edit: That's not it. I don't knoe the reason.
I could be wrong, but I believe it's this line where the children are cloned.
If children is a Fragment it will be treated as a single child and not traversed.
If that is the issue, possible solution with react-is lib and editing this util fn. https://stackoverflow.com/questions/49012718/check-if-a-child-is-react-fragment
Hey @sbrichardson, thanks a lot for sharing those details. I'll work on a fix
I have same the problem. Any progress?
Also running into this issue. Anyone know the last version that this worked on?
Any fix on this?
Also running into this issue.
Facing the same problem in 2023…
Hello I am trying to access pops in the submenu click then getting undefined. is this issue is fixed?