File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
packages/@headlessui-react Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
32
32
- Only check for elements in ` useInertOthers ` ([ #3154 ] ( https://github.com/tailwindlabs/headlessui/pull/3154 ) )
33
33
- Fix anchored elements not flipping when there is padding ([ #3157 ] ( https://github.com/tailwindlabs/headlessui/pull/3157 ) )
34
34
- Render virtual items during an exiting transition ([ #3160 ] ( https://github.com/tailwindlabs/headlessui/pull/3160 ) )
35
+ - Only render virtual options wrapper when there are items to show ([ #3161 ] ( https://github.com/tailwindlabs/headlessui/pull/3161 ) )
35
36
36
37
### Changed
37
38
Original file line number Diff line number Diff line change @@ -449,6 +449,12 @@ function VirtualProvider(props: {
449
449
setBaseKey ( ( v ) => v + 1 )
450
450
} , [ data . virtual ?. options ] )
451
451
452
+ let items = virtualizer . getVirtualItems ( )
453
+
454
+ if ( items . length === 0 ) {
455
+ return null
456
+ }
457
+
452
458
return (
453
459
< VirtualContext . Provider value = { virtualizer } >
454
460
< div
@@ -483,7 +489,7 @@ function VirtualProvider(props: {
483
489
}
484
490
} }
485
491
>
486
- { virtualizer . getVirtualItems ( ) . map ( ( item ) => {
492
+ { items . map ( ( item ) => {
487
493
return (
488
494
< Fragment key = { item . key } >
489
495
{ React . cloneElement (
You can’t perform that action at this time.
0 commit comments