Skip to content

numberProxy, stringProxy don't restore with snapshot restore #435

Closed as not planned
@ryanylee

Description

@ryanylee
  • Before posting an issue, read the FAQ and search the previous issues.

Description
With a form, I have a component like so:

<script context="module" lang="ts">
  import type { FormPathLeaves } from 'sveltekit-superforms';

  type T = Record<string, unknown>;
  type U = unknown;
</script>

<script generics="T extends Record<string, unknown>, U extends FormPathLeaves<T, number>" lang="ts">
  import { numberProxy, fieldProxy, type SuperForm } from 'sveltekit-superforms';

  export let form: SuperForm<T>;
  export let name: U;

  const proxy = numberProxy(form, name, { empty: 'zero', initiallyEmptyIfZero: true });
</script>

<input {name} {...$$restProps} type="number" bind:value={$proxy} />

However, when I restore from a snapshot, the field resolves to the default zod value rather than the cached value. fieldProxy works correctly and shows the right value

If applicable, a MRE
Use this template project to create a minimal reproducible example that you can link to here: https://sveltelab.dev/github.com/ciscoheat/superforms-examples/tree/zod (right click to open in a new tab)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions