Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix(combobox): Fix filtering for custom object shapes using itemToString function

Andrey Okonetchnikov1c9f1ac2e2df
diff --git a/packages/design-system/src/components/combobox.tsx b/packages/design-system/src/components/combobox.tsx
index c98a516a53..9ce2ddb40f 100644
--- a/packages/design-system/src/components/combobox.tsx
+++ b/packages/design-system/src/components/combobox.tsx
@@ -216,11 +216,9 @@ export const Combobox = <Item extends BaseItem>({
*/
itemToString,
onInputValueChange({ inputValue }) {
- const options =
- typeof items[0] === "object" && "label" in items[0]
- ? { keys: ["label"] }
- : undefined;
- const foundItems = matchSorter(items, inputValue ?? "", options);
+ const foundItems = matchSorter(items, inputValue ?? "", {
+ keys: [itemToString],
+ });
setFoundItems(foundItems);
},
onSelectedItemChange({ selectedItem }) {