Skip to content

defaultValue is not working in <input type=text> when the initial value is null #14558

@paulovieira

Description

@paulovieira

Describe the bug

Documentation says:

Since 5.6.0, if an <input> has a defaultValue, it will revert to that value instead of the empty string when the form is reset. Note that for the initial render the value of the binding takes precedence unless it is null or undefined.

https://svelte.dev/docs/svelte/bind#input-bind:value

But if the initial value of the binding is null nothing is happening.

Reproduction

Logs

No response

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1255U
    Memory: 3.40 GB / 15.33 GB
    Container: Yes
    Shell: 5.2.32 - /nix/store/qqz0gj9iaidabp7g34r2fb9mds6ahk8i-bash-interactive-5.2p32/bin/bash
  Binaries:
    Node: 22.9.0 - /nix/store/f9yl8nlgcyazflxc2nj1cr9k9ika7v7z-nodejs-22.9.0/bin/node
    npm: 10.8.3 - /nix/store/f9yl8nlgcyazflxc2nj1cr9k9ika7v7z-nodejs-22.9.0/bin/npm
    pnpm: 9.7.1 - /nix/store/0dvag1syzkbzrjdpppabnkws2vki5wr3-corepack-nodejs-22.9.0/bin/pnpm
  Browsers:
    Chrome: 131.0.6778.85

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions