nuxt / nuxt/icon

Unexpected behaviour when using an Icon within ClientOnly fallback

Open
#129 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.2k
Forks
96
Avg merge
8h 12m
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Vue reproduction using ClientOnly, its #fallback slot, Icon, and the content div with ref="someRef". Compare loading and completed rendering with and without the ref, then trace the relevant Icon and ClientOnly behavior. Done means the fallback shows a large spinner while the completed content keeps normal text sizing when the ref is present.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.