Skip to content
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

Popover using anchor prop in PopoverPanel hangs unit test #3339

Closed
restrin-extensis opened this issue Jun 27, 2024 · 1 comment · Fixed by #3357
Closed

Popover using anchor prop in PopoverPanel hangs unit test #3339

restrin-extensis opened this issue Jun 27, 2024 · 1 comment · Fixed by #3357
Assignees

Comments

@restrin-extensis
Copy link

restrin-extensis commented Jun 27, 2024

What package within Headless UI are you using?
@headlessui/react

What version of that package are you using?
2.1

Adding this unit test to popover.test.tsx reproduces the problem

describe('Popover', () => {
    it(
      'should open panel with anchor prop',
      suppressConsoleLogs(async () => {
        render(
          <Popover>
            <PopoverButton>Trigger</PopoverButton>
            <PopoverPanel anchor="bottom">Panel open</PopoverPanel>
          </Popover>
        )

        assertPopoverButton({
          state: PopoverState.InvisibleUnmounted,
          attributes: { id: 'headlessui-popover-button-1' },
        })
        assertPopoverPanel({ state: PopoverState.InvisibleUnmounted })

        await click(getPopoverButton())

        assertPopoverButton({
          state: PopoverState.Visible,
          attributes: { id: 'headlessui-popover-button-1' },
        })
        assertPopoverPanel({ state: PopoverState.Visible, textContent: 'Panel open' })
      })
    )
   

The problem seems to be within useFixScrollingPixel while setting the max height which resolves to NaN and this method is infinitely called.
image

maxHeight: "min(var(--anchor-max-height, 100vh), 0px)"

@restrin-extensis restrin-extensis changed the title Popover using anchor prop in PopoverPanel hangs during unit test Popover using anchor prop in PopoverPanel hangs unit test Jun 28, 2024
@RobinMalfait RobinMalfait self-assigned this Jul 3, 2024
@RobinMalfait
Copy link
Member

Hey! First of all, thank you very much for the test that reproduces the issue, this was very helpful, as well as your initial debugging here!

This should be fixed by #3357, and will be available in the next release.

You can already try it using:

  • npm install @headlessui/react@insiders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants