tailwindlabs / headlessui

Completely unstyled, fully accessible UI components, designed to integrate beautifully with Tailwind CSS.
https://headlessui.com
MIT License
25.81k stars 1.07k forks source link

Combobox virtual feature randomly gives an error: Uncaught Error: Unexpected undefined at notUndefined at Virtualizer.getOffsetForIndex #3353

Closed JCMais closed 3 months ago

JCMais commented 3 months ago

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v2.1.1

What browser are you using?

Chrome, but does not matter

Reproduction URL

https://codesandbox.io/p/devbox/still-leftpad-xr4zpk?file=%2Fsrc%2FCombobox.jsx&embed=1

Steps to reproduce:

  1. click the field
  2. clear the input (type "a")
  3. press enter
  4. error happens

Describe your issue I am randomly getting the error: Error: Unexpected undefined when the list is empty.

image

I think one possible fix here is to bump the @tanstack/react-virtual package to the latest version and disable the virtualizer when the list is empty

This is related to this ticket https://github.com/TanStack/virtual/issues/696 and the related link PR: https://github.com/TanStack/virtual/pull/741

RobinMalfait commented 3 months ago

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

You can already try it using: