Skip to content

Commit d65829b

Browse files
authored
Fix crash in Combobox component when in virtual mode when options are empty (#3356)
* bump `@tanstack/react-virtual` * only enable the virtualizer when there are options * update changelog
1 parent 990b179 commit d65829b

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@headlessui-react/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Fix prematurely added anchoring styles on `ListboxOptions` ([#3337](https://github.com/tailwindlabs/headlessui/pull/3337))
1313
- Ensure `unmount` on `Dialog` works in combination with the `transition` prop on `DialogBackdrop` and `DialogPanel` components ([#3352](https://github.com/tailwindlabs/headlessui/pull/3352))
14+
- Fix crash in `Combobox` component when in `virtual` mode when options are empty ([#3356](https://github.com/tailwindlabs/headlessui/pull/3356))
1415

1516
## [2.1.1] - 2024-06-26
1617

packages/@headlessui-react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
},
5656
"dependencies": {
5757
"@floating-ui/react": "^0.26.16",
58-
"@tanstack/react-virtual": "3.5.0",
5958
"@react-aria/focus": "^3.17.1",
60-
"@react-aria/interactions": "^3.21.3"
59+
"@react-aria/interactions": "^3.21.3",
60+
"@tanstack/react-virtual": "^3.8.1"
6161
}
6262
}

packages/@headlessui-react/src/components/combobox/combobox.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ function VirtualProvider(props: {
467467
}, [data.optionsRef.current])
468468

469469
let virtualizer = useVirtualizer({
470+
enabled: options.length !== 0,
470471
scrollPaddingStart: paddingStart,
471472
scrollPaddingEnd: paddingEnd,
472473
count: options.length,

0 commit comments

Comments
 (0)