From 512bf441507a4a0263dffb9dd957c966a6584c56 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 15 Apr 2024 17:42:59 +0200 Subject: [PATCH] Ensure the `multiple` prop is typed correctly when passing explicit types to the `Combobox` component (#3099) * ensure `TMultiple` is correct when passing explicit types to the `Combobox` When you use the `Combobox` component with explicit types: ```ts /> ``` Then we make sure that we properly set the `TMultiple` prop as well. It defaults to `false` which seems to be the better default. * update changelog --- packages/@headlessui-react/CHANGELOG.md | 1 + .../src/components/combobox/combobox.tsx | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/@headlessui-react/CHANGELOG.md b/packages/@headlessui-react/CHANGELOG.md index 02f958c..bb9e43a 100644 --- a/packages/@headlessui-react/CHANGELOG.md +++ b/packages/@headlessui-react/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Keep focus inside of the `` component ([#3073](https://github.com/tailwindlabs/headlessui/pull/3073)) - Fix enter transitions for the `Transition` component ([#3074](https://github.com/tailwindlabs/headlessui/pull/3074)) - Render hidden form input fields for `Checkbox`, `Switch` and `RadioGroup` components ([#3095](https://github.com/tailwindlabs/headlessui/pull/3095)) +- Ensure the `multiple` prop is typed correctly when passing explicit types to the `Combobox` component ([#3099](https://github.com/tailwindlabs/headlessui/pull/3099)) ### Changed diff --git a/packages/@headlessui-react/src/components/combobox/combobox.tsx b/packages/@headlessui-react/src/components/combobox/combobox.tsx index 900ec34..7eb1362 100644 --- a/packages/@headlessui-react/src/components/combobox/combobox.tsx +++ b/packages/@headlessui-react/src/components/combobox/combobox.tsx @@ -1830,11 +1830,12 @@ function OptionFn< // --- export interface _internal_ComponentCombobox extends HasDisplayName { - ( - props: ComboboxProps & RefProp - ): JSX.Element - ( - props: ComboboxProps & RefProp + < + TValue, + TMultiple extends boolean | undefined = false, + TTag extends ElementType = typeof DEFAULT_COMBOBOX_TAG, + >( + props: ComboboxProps & RefProp ): JSX.Element }