You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the children prop of a Menu.Item is a class component or a function which returns a class component, opening the menu causes a crash with
Failed to execute 'compareDocumentPosition' on 'Node': parameter 1 is not of type 'Node'.
or
o.compareDocumentPosition is not a function
depending on the order of Menu.Items, i.e. depending on whether the class component MenuItem is in position a or b in a.compareDocumentPosition(b).
This error does not occur on v1.5.0. Perhaps something changed with how refs were passed onto the children of Menu.Item? #1168 also looks relevant since I believe it is crashing within sortByDomNode
The text was updated successfully, but these errors were encountered:
Hey! Thank you for your bug report!
Much appreciated! 🙏
This issue occurs because you are not forwarding all the props and the ref to the underlying DOM node. I've updated your CodeSandbox that does this for both the class component and the functional component:
In fact, this issue was also happening in Headless UI 1.5.0 but it was a bit less apparent. This CodeSandbox is the one you provided with version 1.5.0 of Headless UI, one thing you will notice is that you can't click the "Hello" menu item because the props were not forwarded correctly: https://codesandbox.io/s/headlessui-react-menu-example-forked-qggrlm?file=/src/App.js
Will make sure to make this better discoverable via docs / checks in Headless UI itself but have to think about a good solution for this.
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
For example: v1.6.0
What browser are you using?
Chrome
Reproduction URL
https://codesandbox.io/s/headlessui-react-menu-example-forked-d79l6j?file=/src/App.js
Describe your issue
When the
children
prop of aMenu.Item
is a class component or a function which returns a class component, opening the menu causes a crash withor
depending on the order of
Menu.Item
s, i.e. depending on whether the class component MenuItem is in positiona
orb
ina.compareDocumentPosition(b)
.This error does not occur on v1.5.0. Perhaps something changed with how refs were passed onto the children of
Menu.Item
? #1168 also looks relevant since I believe it is crashing withinsortByDomNode
The text was updated successfully, but these errors were encountered: