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

Fix crash in `Combobox` component when in `virtual` mode when options are empty #3356

Closed RobinMalfait closed 3 months ago

RobinMalfait commented 3 months ago

This PR fixes an issue where using @tanstack/react-virtual with an empty array could lead to crashes such as:

Error: Unexpected undefined

Providing an empty array can happen if you filter the options based on the value of the ComboboxInput.

This PR fixes that by bumping the @tanstack/react-virtual library and using the enabled value and disable it when no options are given.

Fixes: #3353

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2024 10:13pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2024 10:13pm
thecrypticace commented 3 months ago

I wasn't able to repro this originally but based on the fix in tanstack it was timing related so I think this is fine to merge 👍

RobinMalfait commented 3 months ago

I could reproduce it locally a few times, but not consistently. However when I switch to the fixed branch (this one) I couldn't reproduce it anymore. When I switch back and try a few times I could reproduce it again.

JCMais commented 2 months ago

thank you so much @RobinMalfait!