airjp73 / rvf

Easy form validation and state management for React and Remix
https://rvf-js.io
MIT License
827 stars 66 forks source link

[Bug]: `onSubmit` type not narrowed by subaction #298

Closed haines closed 1 year ago

haines commented 1 year ago

Which packages are impacted?

What version of these packages are you using?

Please provide a link to a minimal reproduction of the issue.

https://github.com/haines/remix-validated-form-onsubmit-subaction

Steps to Reproduce the Bug or Issue

  1. Create a validator using withZod(z.discriminatedUnion("subaction", [...]))
  2. Create a ValidatedForm using that validator and setting the subaction
  3. Attempt to add an onSubmit handler and find that the data parameter is not narrowed by the subaction

Expected behavior

The data passed to onSubmit is narrowed to the specific case of the discriminated union based on the subaction

Screenshots or Videos

No response

Platform

n/a

Additional context

Related to https://github.com/airjp73/remix-validated-form/issues/270

haines commented 1 year ago

Thanks for turning that around so quickly! ❤️