fix: Fix issue with icon themes not loading for preview nodes (#17869)

Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
Jon
2025-08-01 14:49:45 +01:00
committed by GitHub
parent 731e171e8f
commit 6d1f2cb67e
2 changed files with 42 additions and 7 deletions

View File

@@ -57,6 +57,29 @@ describe('util: Node Icon', () => {
getNodeIconUrl(mock<IconNodeType>({ icon: 'foo', iconUrl: undefined })), getNodeIconUrl(mock<IconNodeType>({ icon: 'foo', iconUrl: undefined })),
).toBeUndefined(); ).toBeUndefined();
}); });
it('should return the iconUrl from nodeType when using https', () => {
expect(
getNodeIconUrl(
mock<IconNodeType>({
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<IconNodeType>({
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', () => { describe('getBadgeIconUrl', () => {

View File

@@ -73,13 +73,25 @@ export function getNodeIconSource(nodeType?: IconNodeType | null): NodeIconSourc
} }
} }
if (nodeType.name && isNodePreviewKey(nodeType.name) && typeof nodeType.iconUrl === 'string') { if (nodeType.name && isNodePreviewKey(nodeType.name)) {
// If node type is a node preview it would have full icon url // Handle both string and object iconUrl for preview nodes
if (typeof nodeType.iconUrl === 'string') {
return { return {
type: 'file', type: 'file',
src: nodeType.iconUrl, src: nodeType.iconUrl,
badge: undefined, 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); const iconUrl = getNodeIconUrl(nodeType);