From ca6a455a3aec8682033dd5595c10abd4330fd4f9 Mon Sep 17 00:00:00 2001 From: Konrad Schultz Date: Thu, 18 Jul 2024 06:58:49 -0700 Subject: [PATCH] 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. --- .../@headlessui-react/src/components/combobox/combobox.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/@headlessui-react/src/components/combobox/combobox.tsx b/packages/@headlessui-react/src/components/combobox/combobox.tsx index 1fc681a..20b1652 100644 --- a/packages/@headlessui-react/src/components/combobox/combobox.tsx +++ b/packages/@headlessui-react/src/components/combobox/combobox.tsx @@ -636,8 +636,10 @@ export type ComboboxProps< name?: string immediate?: boolean virtual?: { - options: NoInfer[] - disabled?: (value: NoInfer) => boolean + options: TMultiple extends true ? EnsureArray> : NoInfer[] + disabled?: ( + value: TMultiple extends true ? EnsureArray>[number] : NoInfer + ) => boolean } | null onClose?(): void