Skip to content

Commit b68d29b

Browse files
authored
feat: Suggest a variable when user forgets -- in advanced panel (#4850)
#4804 ## Description When user is trying to create a variable but forgot to add --, we can help <img width="258" alt="image" src="https://github.com/user-attachments/assets/689b33a3-5044-461b-bafa-6cac9bbcc3b2" /> ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file
1 parent 1c08434 commit b68d29b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

apps/builder/app/builder/features/style-panel/sections/advanced/advanced.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ const matchOrSuggestToCreate = (
137137
label: `Create "${propertyName}"`,
138138
});
139139
}
140+
// When there is no match we suggest to create a custom property.
141+
if (matched.length === 0) {
142+
matched.unshift({
143+
value: `--${propertyName}`,
144+
label: `--${propertyName}`,
145+
});
146+
}
140147
return matched;
141148
};
142149

@@ -257,8 +264,15 @@ const AddProperty = forwardRef<
257264
<ComboboxListboxItem
258265
{...combobox.getItemProps({ item, index })}
259266
key={index}
267+
asChild
260268
>
261-
{item.label}
269+
<Text
270+
variant="labelsSentenceCase"
271+
truncate
272+
css={{ maxWidth: "25ch" }}
273+
>
274+
{item.label}
275+
</Text>
262276
</ComboboxListboxItem>
263277
))}
264278
</ComboboxScrollArea>

packages/design-system/src/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,5 @@ export const useResize = ({
145145
export const truncate = (): CSS => ({
146146
whiteSpace: "nowrap",
147147
textOverflow: "ellipsis",
148-
overflow: "hidden",
148+
overflow: "clip",
149149
});

0 commit comments

Comments
 (0)