Skip to content
Source
Sign inSign up
TanStack/form

[v2] Port submit metadata support from v1 #2303

OpenLeCarbonator(GitHub profile, opens in a new tab) opened this issue 1 comment

Submit metadata has not yet been implemented in v2. Adding it would allow metadata associated with a submission to remain available throughout the relevant form lifecycle.

Submit metadata should be available in the following places:

  • Validators: Optional, because a validator may run for an event other than submission.
  • Listeners: Always optional to keep the shared listener context manageable.
  • onSubmit: Required. The callback should receive the effective metadata, using the per-submission override when provided and the configured default otherwise.

Some thoughts

For validators, a discriminated union with a submit event could make the metadata available with stronger type safety only when the event is a submission. Listener metadata should likely remain optional because expressing the same relationship in the shared listener types may be too cumbersome.

  1. LeCarbonator(GitHub profile, opens in a new tab) added labelstype: enhancement

  2. LeCarbonator(GitHub profile, opens in a new tab) added labelsscope: core

  3. LeCarbonator(GitHub profile, opens in a new tab) added labelsarea: runtime

  4. LeCarbonator(GitHub profile, opens in a new tab) added labelsarea: types

  5. Hi @LeCarbonator, I'd like to take this. My plan, following your notes:

    • a default meta on form options, with an optional per-submit override on handleSubmit
    • onSubmit always receives the resolved meta
    • validators get it through a union on the event, so it's typed only for submits
    • listeners get it as optional

    Is this safe to start on alpha now, or should it wait for the submission rework / #2306?

Sign in to join this conversation.