-
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
Headless v2 makes resizeObserver mandatory for testing #3268
Comments
Hey! The good news is that You can do a few things:
import ResizeObserver from 'resize-observer-polyfill'
global.ResizeObserver = ResizeObserver
So going to close this for now because I don't consider this a bug of Headless UI. If we rely on new features of JavaScript that aren't available in major browsers we will make sure to polyfill them internally. Hope this helps! |
To make it clear, I don't think this is a bug of Headless UI too. It's a bug in the v2 docs, which don't mention this. |
…2200) * chore(deps): bump @headlessui/react from 1.7.19 to 2.1.1 in /website Bumps [@headlessui/react](https://github.com/tailwindlabs/headlessui/tree/HEAD/packages/@headlessui-react) from 1.7.19 to 2.1.1. - [Release notes](https://github.com/tailwindlabs/headlessui/releases) - [Changelog](https://github.com/tailwindlabs/headlessui/blob/main/packages/@headlessui-react/CHANGELOG.md) - [Commits](https://github.com/tailwindlabs/headlessui/commits/@headlessui/react@v2.1.1/packages/@headlessui-react) --- updated-dependencies: - dependency-name: "@headlessui/react" dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * chore(website): migrate headless ui to use DialogPanel instead of Dialog.Overlay See https://github.com/tailwindlabs/headlessui/releases/tag/%40headlessui%2Freact%40v1.6.0 for migration guide * chore(website): address Combobox nullable breaking change for headless-ui v2 see tailwindlabs/headlessui#3064 * chore(website): appease typescript for headlessui v2 upgrade for nullable combobox Headlessui v2 makes it necessary to handle null input for combobox. See tailwindlabs/headlessui#3064 * chore(website): address headlessui v2 deprecation warnings due to renamings * chore(website): use focus instead of deprecated active, headlessui v2 migration see https://github.com/tailwindlabs/headlessui/releases/tag/%40headlessui%2Freact%40v2.0.0#user-content-upgrading-from-v1 * chore(website): mock ResizeObserver, neccesary for headlessui v2 see tailwindlabs/headlessui#3268 * Use new `immediate` feature of headlessui v2 * Fix flaky test by waiting for modal to be removed * fix failing test by using userEvent.click instead of fireEvent.click * chore: address warnings/lints --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Cornelius Roemer <cornelius.roemer@gmail.com>
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v2.0.4
What browser are you using?
jest
Describe your issue
After migrating to headless ui v2, most tests seem to fail due to us not having a resizeObserver.
I can get around this by mocking this globally:
Comments here also suggest this, but I have never seen it on v1 #2832 (reply in thread)
The text was updated successfully, but these errors were encountered: