Skip to content

Commit 4fbb8e2

Browse files
committed
drop test environment in virtualizer
1 parent 63daa86 commit 4fbb8e2

File tree

2 files changed

+17
-31
lines changed

2 files changed

+17
-31
lines changed

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -532,21 +532,14 @@ function VirtualProvider(props: {
532532
return
533533
}
534534

535-
// Scroll to the active index
536-
{
537-
// Ignore this when we are in a test environment
538-
if (typeof process !== 'undefined' && process.env.JEST_WORKER_ID !== undefined) {
539-
return
540-
}
541-
542-
// Do not scroll when the mouse/pointer is being used
543-
if (data.activationTrigger === ActivationTrigger.Pointer) {
544-
return
545-
}
535+
// Do not scroll when the mouse/pointer is being used
536+
if (data.activationTrigger === ActivationTrigger.Pointer) {
537+
return
538+
}
546539

547-
if (data.activeOptionIndex !== null && options.length > data.activeOptionIndex) {
548-
virtualizer.scrollToIndex(data.activeOptionIndex)
549-
}
540+
// Scroll to the active index
541+
if (data.activeOptionIndex !== null && options.length > data.activeOptionIndex) {
542+
virtualizer.scrollToIndex(data.activeOptionIndex)
550543
}
551544
}}
552545
>

packages/@headlessui-vue/src/components/combobox/combobox.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -190,24 +190,17 @@ let VirtualProvider = defineComponent({
190190
return
191191
}
192192

193-
// Scroll to the active index
194-
{
195-
// Ignore this when we are in a test environment
196-
if (typeof process !== 'undefined' && process.env.JEST_WORKER_ID !== undefined) {
197-
return
198-
}
199-
200-
// Do not scroll when the mouse/pointer is being used
201-
if (api.activationTrigger.value === ActivationTrigger.Pointer) {
202-
return
203-
}
193+
// Do not scroll when the mouse/pointer is being used
194+
if (api.activationTrigger.value === ActivationTrigger.Pointer) {
195+
return
196+
}
204197

205-
if (
206-
api.activeOptionIndex.value !== null &&
207-
api.virtual.value!.options.length > api.activeOptionIndex.value
208-
) {
209-
virtualizer.value.scrollToIndex(api.activeOptionIndex.value)
210-
}
198+
// Scroll to the active index
199+
if (
200+
api.activeOptionIndex.value !== null &&
201+
api.virtual.value!.options.length > api.activeOptionIndex.value
202+
) {
203+
virtualizer.value.scrollToIndex(api.activeOptionIndex.value)
211204
}
212205
},
213206
},

0 commit comments

Comments
 (0)