Skip to content

Commit ca0e1d7

Browse files
authored
fix: show correct component icons in command panel (#5261)
Missed command panel case <img width="487" alt="Screenshot 2025-06-10 at 10 05 39" src="https://github.com/user-attachments/assets/6a2f738c-dd7d-4701-91aa-c0dcdbe669f1" />
1 parent 31cf38d commit ca0e1d7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

apps/builder/app/builder/features/command-panel/command-panel.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ type ComponentOption = {
102102
category: TemplateMeta["category"];
103103
icon: undefined | string;
104104
order: undefined | number;
105+
firstInstance: { component: string };
105106
};
106107

107108
const getComponentScore = (meta: ComponentOption) => {
@@ -158,6 +159,7 @@ const $componentOptions = computed(
158159
category,
159160
icon: meta.icon,
160161
order: meta.order,
162+
firstInstance: { component: name },
161163
});
162164
}
163165
for (const [name, meta] of templates) {
@@ -188,6 +190,7 @@ const $componentOptions = computed(
188190
category: meta.category,
189191
icon: meta.icon ?? componentMeta?.icon,
190192
order: meta.order,
193+
firstInstance: meta.template.instances[0],
191194
});
192195
}
193196
componentOptions.sort(
@@ -205,7 +208,7 @@ const ComponentOptionsGroup = ({ options }: { options: ComponentOption[] }) => {
205208
heading={<CommandGroupHeading>Components</CommandGroupHeading>}
206209
actions={["add"]}
207210
>
208-
{options.map(({ component, label, category, icon }) => {
211+
{options.map(({ component, label, category, icon, firstInstance }) => {
209212
return (
210213
<CommandItem
211214
key={component}
@@ -225,7 +228,7 @@ const ComponentOptionsGroup = ({ options }: { options: ComponentOption[] }) => {
225228
>
226229
<Flex gap={2}>
227230
<CommandIcon>
228-
<InstanceIcon instance={{ component }} icon={icon} />
231+
<InstanceIcon instance={firstInstance} icon={icon} />
229232
</CommandIcon>
230233
<Text variant="labelsTitleCase">
231234
{label}{" "}

0 commit comments

Comments
 (0)