-
Notifications
You must be signed in to change notification settings - Fork 4.8k
ControlWithError: Show validating state when transitioning from error state #71260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dea1939
Add tests
mirka 1046981
ControlWithError: Show validating state when transitioning from error…
mirka ef64fa6
Add changelog
mirka 125b759
Mimic a stable server response time
mirka 0adf893
Prefer `toBeVisible` in tests
mirka a50671f
Fix useEffect return type weirdness
mirka ffa9e22
Add test for deferring local validity state until server response is …
mirka b256311
Add play function
mirka 8f4198b
Wait for async response before showing local state
mirka bc50407
Don't export test story
mirka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ControlWithError: Show validating state when transitioning from error…
… state
- Loading branch information
commit 1046981d3ce1ca62afb06656d8945e6b76b2fc25
There are no files selected for viewing
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe in this case we want to
setErrorMessage( undefined )? There is no error while validation is running.The use case is interaction of the
onValidatecustom (server-side) validation with client-side validation, e.g., when there is something like<input type="email">and the value is not email.In that case, when additional custom validation is in flight, and status is
validating, do we wanterrorMessageto show the "not email" error or not.I'm not sure if we even support this combination of custom and native validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be adding tests soon to help document these intended behaviors, but yes, we do support the combination of attribute-based and
customValidity. I tried to match how the native APIs handle it, in that thecustomValiditymessage will be prioritized when it's a non-empty string, but otherwise the rest of the attribute-based validation errors will remain. It also matches the native browser logic of how errors messages are displayed — there can be multiple errors but only one error message is shown at a time.That's a good question. I'm not sure if there's a universally better behavior, but I think in the general case, yes, we do want to show the "not email" error without waiting for the custom validator result.
Let's say there's a 50/50 chance of the custom async validator responding as error, and we wait for the async result before notifying the user about the "not email" error. This means that 50% of the time we made the user wait for no reason, because we already knew about the "not email" error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out, in practice it did feel better to make the user wait in all cases 😅 Going with
setErrorMessage( undefined )as in your suggestion.