Skip to content

Commit ca6a455

Browse files
authored
Fix Combobox virtual mode types for multiple (#3392)
When multiple is specified we expect TValue to already be an array, so lets just ensure its an array and use it as the type for virtual.options. Similarly the disabled callback gets passed a TValue, but when multiple is true it is passed something of type element of TValue. Behaviour in javascript lines up with this fine, just a type level fix afaik.
1 parent f335372 commit ca6a455

File tree

1 file changed

+4
-2
lines changed
  • packages/@headlessui-react/src/components/combobox

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,10 @@ export type ComboboxProps<
636636
name?: string
637637
immediate?: boolean
638638
virtual?: {
639-
options: NoInfer<TValue>[]
640-
disabled?: (value: NoInfer<TValue>) => boolean
639+
options: TMultiple extends true ? EnsureArray<NoInfer<TValue>> : NoInfer<TValue>[]
640+
disabled?: (
641+
value: TMultiple extends true ? EnsureArray<NoInfer<TValue>>[number] : NoInfer<TValue>
642+
) => boolean
641643
} | null
642644

643645
onClose?(): void

0 commit comments

Comments
 (0)