feat(Forms): support return messages from onSubmitRequest#7078
Merged
Conversation
|
Branch Preview URL (stable): Deployment URL (unique): |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Allow onSubmitRequest to return error, warning, info, or customStatus messages (same as onSubmit). These are displayed at the form level via FormStatus. Supports async functions. - Updated OnSubmitRequest type to return OnSubmitRequestReturn - Handle return value in Provider handleSubmitCall - Added docs and demo example - Added tests for all message types and error flow transition
fce8a8d to
24ee497
Compare
commit: |
tujoworker
reviewed
Mar 19, 2026
Member
tujoworker
left a comment
There was a problem hiding this comment.
Would be nice if it would be possible to reuse the same logic/code from what we already have for onSubmit.
Reduce duplication between onSubmit and onSubmitRequest result handling by extracting two shared helpers: - resolveStateResult: try/catch with Error instance handling - applySubmitState: conditional setSubmitState for error/warning/info/customStatus
Contributor
Author
Done so now 🙏 |
Merged
Previously, only error and customStatus were cleared at the start of handleSubmitCall. Warning and info messages from onSubmitRequest would persist after a subsequent successful submit because setSubmitState merges state. Now all four keys are cleared.
tujoworker
approved these changes
Mar 20, 2026
tujoworker
pushed a commit
that referenced
this pull request
Mar 20, 2026
## [10.101.0](v10.100.1...v10.101.0) (2026-03-20) ### 📝 Documentation * improve naming docs ([#7020](#7020)) ([b398e5a](b398e5a)) ### 🐛 Bug Fixes * **Field.Date:** add validation error when range start date is after end date ([#7019](#7019)) ([3142120](3142120)) * **Field.Email:** improve error message ([#7034](#7034)) ([7446b9c](7446b9c)) * **Input, Autocomplete:** memoize `icon` for ProgressIndicator ([#7027](#7027)) ([5b69748](5b69748)), closes [#6449](#6449) * **List:** preserve direct li children in `List.Container` ([#7079](#7079)) ([d86275a](d86275a)) * **Stat.Number:** add missing Number export to barrel index ([#7024](#7024)) ([069e9d0](069e9d0)) * **Stat:** ensure amounts are accessible to screen readers ([#7022](#7022)) ([3131116](3131116)) * update forms validation messages across all locales ([#7043](#7043)) ([7557016](7557016)) ### ✨ Features * **Forms:** support return messages from onSubmitRequest ([#7078](#7078)) ([b63b9fe](b63b9fe)) * **List:** add `List.Card` and `List.ScrollView` ([#7080](#7080)) ([91a04d2](91a04d2))
Member
|
🎉 This PR is included in version 10.101.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation: To be able to display error message or info to user when user tries to submit a form that contains errors.
It could be that the field with the error is far away from the submit button, so that the user may not be able to see the error message for that given field, like in the following example.
Using the functionality added in this PR, the user will be able to see the error message by the submit button.
Reason for not using the same functionality in
onSubmitis becauseonSubmitwill never trigger or fire when there's errors in the form, butonSubmitRequestwill.This PR allows
onSubmitRequestto return error, warning, info, or customStatus messages (same asonSubmit). These are displayed at the form level via FormStatus. Supports async functions.Fix or feat?
Genuinely I believe it's a feat, but somehow I would like to include it in the next bugfix release, hehe.