sveltejs / sveltejs/kit

docs: `defaultChecked` should not be used with form remote functions

Open
#14,707 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation forms
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug
<script lang="ts">
  import { FormSchema } from './ids';
  import { addId } from './ids.remote';
</script>

<form {...addId.preflight(FormSchema)}>
  <fieldset>
    {#each ['windows', 'mac', 'linux'] as os, index}
      <label>
        <!-- windows is not checked -->
        <input {...addId.fields.operatingSystem.as('radio', os)} defaultChecked={!index} />
        {os}
      </label>
    {/each}
  </fieldset>
  <fieldset>
    {#each ['windows', 'mac', 'linux'] as os, index}
      <label>
        <!-- windows is checked -->
        <input type="radio" name="os" value={os} defaultChecked={!index} />
        {os}
      </label>
    {/each}
  </fieldset>
</form>

Happens on both Firefox and Chrome.

Image
<form method="POST" action="?/remote=14dkmo%2FaddId">
  <fieldset>
    <!-- dev tools shows that it is checked, but the UI does not reflect this -->
    <label><input name="operatingSystem" type="radio" value="windows" checked="" /> windows</label
    ><label><input name="operatingSystem" type="radio" value="mac" /> mac</label
    ><label><input name="operatingSystem" type="radio" value="linux" /> linux</label>
  </fieldset>
  <fieldset>
    <label><input type="radio" name="os" value="windows" checked="" /> windows</label
    ><label><input type="radio" name="os" value="mac" /> mac</label
    ><label><input type="radio" name="os" value="linux" /> linux</label>
  </fieldset>
</form>
Reproduction

https://github.com/hyunbinseo/svelte-kit-template/tree/mre-kit-14707

Logs

System Info
System:
  OS: Windows 11 10.0.26100
  CPU: (8) x64 Intel(R) Core(TM) Ultra 7 258V
  Memory: 3.51 GB / 31.48 GB
Binaries:
  Node: 24.10.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\24580_1760341048510\node.EXE
  Yarn: 1.22.22 - C:\Users\hyunb\AppData\Local\fnm_multishells\24580_1760341048510\yarn.CMD
  npm: 11.6.1 - C:\Users\hyunb\AppData\Local\fnm_multishells\24580_1760341048510\npm.CMD
  pnpm: 10.18.2 - C:\Users\hyunb\AppData\Local\fnm_multishells\24580_1760341048510\pnpm.CMD
  Deno: 2.4.0 - C:\Users\hyunb\.deno\bin\deno.EXE
Browsers:
  Chrome: 141.0.7390.76
  Edge: Chromium (140.0.3485.54)
  Firefox: 143.0.4 - C:\Program Files\Mozilla Firefox\firefox.exe
npmPackages:
  @sveltejs/adapter-auto: ^6.1.1 => 6.1.1 
  @sveltejs/kit: ^2.46.5 => 2.46.5 
  @sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.1 
  svelte: ^5.39.11 => 5.39.11 
  vite: ^7.1.7 => 7.1.7
Severity

blocking an upgrade

Additional Information

No response

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

Run the linked reproduction at https://github.com/hyunbinseo/svelte-kit-template/tree/mre-kit-14707 and compare the two fieldsets using defaultChecked. Start by tracing how the form markup for remote functions becomes the generated HTML shown in the issue. Done means defaultChecked visibly selects the first radio in the remote-function form, as it does in the ordinary form.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.