Skip to content

Commit

Permalink
fix: render invalid icon in inserted dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
wwsun committed Mar 27, 2024
1 parent 47364e4 commit 9a78ec0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/designer/src/simulator/selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,19 @@ const insertedItemStyle = css`

function InsertedItem({
label,
icon = 'icon-placeholder',
icon,
description,
...rest
}: HTMLCoralProps<'div'> & Omit<IInsertedData, 'name'>) {
let iconNode;
if (!icon) {
iconNode = <IconFont className="material-icon" type="icon-placeholder" />;
} else if (icon.startsWith('icon-')) {
iconNode = <IconFont className="material-icon" type={icon} />;
} else {
iconNode = <img src={icon} alt={label} />;
}

return (
<Box
display="flex"
Expand All @@ -513,11 +522,7 @@ function InsertedItem({
alignItems="center"
justifyContent="center"
>
{icon.startsWith('icon-') ? (
<IconFont className="material-icon" type={icon} />
) : (
<img src={icon} alt={label} />
)}
{iconNode}
</Box>
<Box>
<Box fontWeight="500">{label}</Box>
Expand Down

0 comments on commit 9a78ec0

Please sign in to comment.