diff --git a/packages/hub-ui/src/client/components/icons/IconifyIcon.vue b/packages/hub-ui/src/client/components/icons/IconifyIcon.vue index 7a210ccae..41bfc8278 100644 --- a/packages/hub-ui/src/client/components/icons/IconifyIcon.vue +++ b/packages/hub-ui/src/client/components/icons/IconifyIcon.vue @@ -20,29 +20,43 @@ const iconifyParsed = computed(() => { }) const iconifyLoaded = ref(undefined) -watchEffect(async () => { - if (!iconifyParsed.value) { - iconifyLoaded.value = undefined +const failed = ref(false) +watchEffect(async (onCleanup) => { + let active = true + onCleanup(() => { + active = false + }) + iconifyLoaded.value = undefined + failed.value = false + if (!iconifyParsed.value) return - } try { - iconifyLoaded.value = await getIconifySvg(iconifyParsed.value.collection, iconifyParsed.value.icon) + const svg = await getIconifySvg(iconifyParsed.value.collection, iconifyParsed.value.icon) + if (active) + iconifyLoaded.value = svg } catch { - // A failed icon fetch (offline / flaky CDN) should degrade to a blank icon, - // not throw out of the async effect and crash the surrounding panel. - iconifyLoaded.value = undefined + /** Keep fetch failures local to the icon so the surrounding panel remains usable. */ + if (active) + failed.value = true } })