nuxt / icon

The <Icon> component, supporting Iconify, Emojis and custom components.
https://stackblitz.com/edit/nuxt-icon-playground?file=app.vue
MIT License
868 stars 37 forks source link

Unexpected behaviour when using an Icon within ClientOnly fallback #129

Open slugcat-dev opened 6 months ago

slugcat-dev commented 6 months ago

Consider following code for your app:

<style>
.loading {
  font-size: 2rem;
}
</style>

<template>
  <ClientOnly>
    <template #fallback>
      <div class="loading">
        <Icon name="svg-spinners:ring-resize" />
        Loading
      </div>
    </template>
    <div class="content" ref="someRef">
      This text should NOT be large!
      Remove the <pre>ref="someRef"</pre> from the parent and it works
    </div>
  </ClientOnly>
</template>

Expected behaviour when loading the page: A big loading spinner, and, when everything is done loading, some normal text, like this: image

Instead, you get this: image

When you remove the ref="someRef" from the content div, it works as expected

Atinux commented 6 months ago

Are you sure this is from Nuxt icon directly and not Nuxt itself?

slugcat-dev commented 6 months ago

Can't tell, but when you remove the Icon from the template, it works

Atinux commented 6 months ago

Could you try with <IconCSS name="svg-spinners:ring-resize" />?

slugcat-dev commented 6 months ago

Already tried that, it doesn't work either

Atinux commented 6 months ago

Can you create a reproduction with Stackblitz please?

slugcat-dev commented 6 months ago

https://stackblitz.com/edit/nuxt-icon-playground-ct93e9?file=app.vue