-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cannot read properties of undefined (reading 'headlessuiFocusGuard') in 1.7.6+ #2196
Comments
Hey! Thank you for your bug report! Is your jest setup so that it includes a DOM (using |
Yeah, the environment is set to |
I started facing this at |
@mizozobu can you create a minimal reproduction? |
I should trust the type system a bit more! You can already try it using:
|
Awesome! Thank you. Just out of curiosity, do you know what other types relatedTarget can be besides |
What package within Headless UI are you using?
For example: @headlessui/react
What version of that package are you using?
For example: v1.7.6 and v1.7.7
What browser are you using?
Jest
Reproduction URL
Describe your issue
I'm running a Jest test that includes clicking on an element within a
<Dialog />
and checking the results. This worked in 1.6.6 but I just upgraded to 1.7.7 and it's now broken. I traced it back and 1.7.5 works fine but somewhere in the 1.7.6 update broke the test. Weirdly, the same code in our live app and in Storybook work fine, just the Jest test breaks with this error.I've traced it to https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/components/focus-trap/focus-trap.tsx#L115-L118 which looks like it was added in #2093 which was released in 1.7.6.
If I change my test from
userEvent.click
tofireEvent.click
it works fine. The difference being userEvent propagates the event through the event chain, like it would in a browser, which I assume is being caught by the focus trap and breaking.The text was updated successfully, but these errors were encountered: