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: Fix stale descriptions combobox (#3167)

Oleg Isonen2a3a354ed4be
diff --git a/apps/builder/app/builder/features/style-panel/sections/advanced/add.tsx b/apps/builder/app/builder/features/style-panel/sections/advanced/add.tsx
index 073548a11f..94c26c2df4 100644
--- a/apps/builder/app/builder/features/style-panel/sections/advanced/add.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/advanced/add.tsx
@@ -21,11 +21,7 @@ const matchOrSuggestToCreate = (
return matched;
}
- if (
- search.trim() !== "" &&
- itemToString(matched[0]).toLocaleLowerCase() !==
- search.toLocaleLowerCase().trim()
- ) {
+ if (search.trim().startsWith("--")) {
matched.unshift({
value: search.trim(),
label: `Create "${search.trim()}"`,
@@ -60,9 +56,7 @@ export const Add = ({
}}
match={matchOrSuggestToCreate}
getDescription={(item) => {
- let description = `Please look up ${
- item?.value ? `"${toKebabCase(item?.value)}"` : "property"
- } in MDN.`;
+ let description = `Unknown CSS property.`;
if (item && item.value in propertyDescriptions) {
description =
propertyDescriptions[
diff --git a/packages/design-system/src/components/combobox.tsx b/packages/design-system/src/components/combobox.tsx
index fc77071bf3..21aab3c5a3 100644
--- a/packages/design-system/src/components/combobox.tsx
+++ b/packages/design-system/src/components/combobox.tsx
@@ -427,17 +427,14 @@ export const Combobox = <Item,>({
getDescription,
...props
}: UseComboboxProps<Item> & Omit<ComponentProps<"input">, "value">) => {
- const combobox = useCombobox<Item>({
- ...props,
- onItemHighlight: (item) => {
- props.onItemHighlight?.(item);
- setDescription(getDescription?.(item));
- },
- });
+ const combobox = useCombobox<Item>(props);
- const [description, setDescription] = useState<ReactNode>(
- getDescription?.(combobox.items[props.defaultHighlightedIndex ?? -1])
- );
+ const descriptionItem =
+ combobox.highlightedIndex === -1
+ ? combobox.selectedItem
+ : combobox.items[combobox.highlightedIndex];
+
+ const description = getDescription?.(descriptionItem);
return (
<ComboboxRoot open={combobox.isOpen}>