Skip to content

Using a remote number form field with a default value stops you from completely deleting the field value #15937

Description

@big-mike-88

Describe the bug

Let's say you have this basic scenario:

<form {...someForm}>
  <input {...someForm.fields.someField.as('number', 200)}/>
</form>

where the field is defined as z.number().optional(). Hitting backspace on that field will start deleting the zeroes until you reach the "2". Trying to delete further will not delete it, but instead "reset" to the default. It only happens with number fields, text fields are ok.

There's probably a bug where svelte sees that the number field is undefined and then replaces it with the default value. Not sure when this regression happened but i'm 90% sure the previous minor version was ok.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-jgjj2b79?file=src%2Flib%2FInputWrapper.svelte

Go to the first field (type number), start hitting backspace, notice the behavior. Try to also delete the second field which is text, see that it works

Logs

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 22.22.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @sveltejs/adapter-auto: ^7.0.0 => 7.0.1 
    @sveltejs/kit: ^2.48.5 => 2.61.1 
    @sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.4 
    svelte: ^5.43.8 => 5.56.0 
    vite: ^7.2.2 => 7.3.3

Severity

blocking an upgrade

Additional Information

Tested on Firefox and safari.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions