Skip to content

Commit 2dde565

Browse files
mirkaciampo
andauthored
UI: Preserve Combobox source item generics (#84094)
* UI: Preserve Combobox item generics * Docs: Link Combobox type fix changelog Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org>
1 parent e02f866 commit 2dde565

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎packages/ui/CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
### Bug Fixes
3333

34+
- `Combobox.Root`: Preserve separate item and selected-value types for collections, including filtering callbacks ([#84094](https://github.com/WordPress/gutenberg/pull/84094)).
3435
- `Autocomplete.Root`: Preserve item type inference in filtering, formatting, and highlight callbacks for flat and grouped items ([#84095](https://github.com/WordPress/gutenberg/pull/84095)).
3536
- `Breadcrumb`: Keep a custom renderer's ref on the visible item ([#84069](https://github.com/WordPress/gutenberg/pull/84069)).
3637
- `RadioGroup`: Preserve value type inference in callbacks. `RadioGroupControl`: Type selected values and callbacks as strings to match its items ([#83872](https://github.com/WordPress/gutenberg/pull/83872)).

‎packages/ui/src/form/primitives/combobox/root.tsx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ import { DirectionProvider } from '../../../utils/direction-provider';
88
* See `SearchableSelectControl` and `SearchableChipSelectControl` for standard
99
* implementations of a single and multiple selection combobox.
1010
*/
11-
export function Root< Value, Multiple extends boolean | undefined = false >(
12-
props: ComboboxRootProps< Value, Multiple >
13-
) {
11+
export function Root<
12+
Value,
13+
Multiple extends boolean | undefined = false,
14+
Item = Value,
15+
>( props: ComboboxRootProps< Value, Multiple, Item > ) {
1416
return (
1517
<DirectionProvider>
1618
<_Combobox.Root { ...props } />

‎packages/ui/src/form/primitives/combobox/types.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ export type ComboboxPopupProps = ComponentProps< typeof _Combobox.Popup > &
145145
export type ComboboxRootProps<
146146
Value,
147147
Multiple extends boolean | undefined = false,
148-
> = _Combobox.Root.Props< Value, Multiple >;
148+
Item = Value,
149+
> = _Combobox.Root.Props< Value, Multiple, Item >;
149150

150151
export type ComboboxSeparatorProps = Omit<
151152
ComponentProps< typeof _Combobox.Separator >,

0 commit comments

Comments
 (0)