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.

preview highlighted keywords list item on canvas

Oleg Isonen3cfd1b2a3dac
diff --git a/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx b/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx
index 3c9afeb625..cd09e2cd21 100644
--- a/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/text/text-control.tsx
@@ -18,22 +18,30 @@ export const TextControl = ({
const setValue = setProperty(styleConfig.property);
- const [tempValue, setTempValue] = useState<StyleValue>();
+ const [ephemeralValue, setEphemeralValue] = useState<StyleValue | null>(null);
return (
<CssValueInput
property={styleConfig.property}
- value={tempValue ?? value}
+ value={ephemeralValue ?? value}
keywords={styleConfig.items.map((item) => ({
type: "keyword",
value: item.name,
}))}
onChange={(styleValue) => {
- setTempValue(styleValue);
+ setEphemeralValue(styleValue);
setValue(toValue(styleValue), { isEphemeral: true });
}}
+ onItemHighlight={(styleValue) => {
+ const nextValue = styleValue ?? ephemeralValue ?? value;
+ if (nextValue) {
+ setValue(toValue(nextValue), {
+ isEphemeral: true,
+ });
+ }
+ }}
onChangeComplete={(styleValue) => {
- setTempValue(undefined);
+ setEphemeralValue(null);
setValue(toValue(styleValue));
}}
/>
diff --git a/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx b/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx
index 8f2c48f4fe..10ed2fcf8d 100644
--- a/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx
+++ b/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx
@@ -182,7 +182,6 @@ export const CssValueInput = ({
} = useCombobox<StyleValue>({
items: keywords,
value,
- // @todo if we String() the value, it leads to an infinite loop
itemToString: (item) => (item === null ? "" : String(item.value)),
onItemSelect: (value) => {
onChangeComplete(value ?? defaultValue);