ciscoheat / sveltekit-superforms

Making SvelteKit forms a pleasure to use!
https://superforms.rocks
MIT License
2.26k stars 66 forks source link

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

Closed ryanylee closed 1 month ago

ryanylee commented 6 months ago

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)

ciscoheat commented 3 months ago

This seems to work fine for me, any difference for you? https://www.sveltelab.dev/tuc2qb4uru3to33

ciscoheat commented 1 month ago

Closing, no activity