diff --git a/packages/frontend/editor-ui/src/utils/nodeIcon.test.ts b/packages/frontend/editor-ui/src/utils/nodeIcon.test.ts index e14b60fec4..39872a751d 100644 --- a/packages/frontend/editor-ui/src/utils/nodeIcon.test.ts +++ b/packages/frontend/editor-ui/src/utils/nodeIcon.test.ts @@ -57,6 +57,29 @@ describe('util: Node Icon', () => { getNodeIconUrl(mock({ icon: 'foo', iconUrl: undefined })), ).toBeUndefined(); }); + + it('should return the iconUrl from nodeType when using https', () => { + expect( + getNodeIconUrl( + mock({ + iconUrl: 'https://my-site.com/icon.svg', + }), + ), + ).toBe('https://my-site.com/icon.svg'); + }); + + it('should return the iconUrl from nodeType when using https with themed values', () => { + expect( + getNodeIconUrl( + mock({ + iconUrl: { + light: 'https://my-site.com/light-icon.svg', + dark: 'https://my-site.com/dark-icon.svg', + }, + }), + ), + ).toBe('https://my-site.com/light-icon.svg'); + }); }); describe('getBadgeIconUrl', () => { diff --git a/packages/frontend/editor-ui/src/utils/nodeIcon.ts b/packages/frontend/editor-ui/src/utils/nodeIcon.ts index 7fec0696f7..15e2557372 100644 --- a/packages/frontend/editor-ui/src/utils/nodeIcon.ts +++ b/packages/frontend/editor-ui/src/utils/nodeIcon.ts @@ -73,13 +73,25 @@ export function getNodeIconSource(nodeType?: IconNodeType | null): NodeIconSourc } } - if (nodeType.name && isNodePreviewKey(nodeType.name) && typeof nodeType.iconUrl === 'string') { - // If node type is a node preview it would have full icon url - return { - type: 'file', - src: nodeType.iconUrl, - badge: undefined, - }; + if (nodeType.name && isNodePreviewKey(nodeType.name)) { + // Handle both string and object iconUrl for preview nodes + if (typeof nodeType.iconUrl === 'string') { + return { + type: 'file', + src: nodeType.iconUrl, + badge: undefined, + }; + } else if (nodeType.iconUrl && typeof nodeType.iconUrl === 'object') { + // Use getThemedValue to get the appropriate theme URL + const themedUrl = getThemedValue(nodeType.iconUrl, useUIStore().appliedTheme); + if (themedUrl) { + return { + type: 'file', + src: themedUrl, + badge: undefined, + }; + } + } } const iconUrl = getNodeIconUrl(nodeType);