feat(form-core): Async field onChange with submition handling #1562
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!
Async field level
onChange
handlers was one of the features that made me want to switch toTanstack/form
but I ran into a problem where I wanted to modify the value of the field using a debounced async function on theonChange
but when submitting the form I want to ensure that the asynconChange
has been correctly ran before allowing submission/validation.A concrete example is in a dynamic form I have users can add image upload fields, that I want to begin uploading to s3
onChange
, but they should not be allowed to submit unless the upload function has been completed successfully and pressing submit should begin loading until all the actions/uploads are completed.I have thrown together a working, but maybe not perfect implementation, and modified the simple example to allow playing around with it. I would be happy to finish the feature if others also agree this would be a good feature :)