-
Notifications
You must be signed in to change notification settings - Fork 10
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
Clear field error state if the field is cleared #2424
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
566aefc
clear error state in multiselect when shortcuts are used
beaesguerra 6a2ceee
docs(changeset): MultiSelect: Clear error state when "Select none" or…
beaesguerra 7800d39
clear field error if value changes to an empty string. this clears an…
beaesguerra 7eca261
update LabeledTextField test so it is testing validation for a specif…
beaesguerra c7ce167
[wb-1846] add hook unit tests
beaesguerra b5fb688
[wb-1846] add tests for clearing the error when a field is cleared fo…
beaesguerra d8e0485
[wb-1846-clear-error] docs(changeset): TextField, TextArea, SearchFie…
beaesguerra 2b73c6f
Revert "[wb-1846-clear-error] docs(changeset): TextField, TextArea, S…
beaesguerra fd331f5
Revert "[wb-1846] add tests for clearing the error when a field is cl…
beaesguerra 941cef2
Revert "[wb-1846] add hook unit tests"
beaesguerra 25c4fac
Revert "update LabeledTextField test so it is testing validation for …
beaesguerra a993ea9
Revert "clear field error if value changes to an empty string. this c…
beaesguerra 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
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@khanacademy/wonder-blocks-search-field": patch | ||
"@khanacademy/wonder-blocks-form": patch | ||
--- | ||
|
||
TextField, TextArea, SearchField: Clear error state when field is cleared and it is not required |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/wonder-blocks-dropdown": patch | ||
--- | ||
|
||
MultiSelect: Clear error state when "Select none" or "Select all" shortcuts are used |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -704,7 +704,7 @@ describe("Required LabeledTextField", () => { | |
const errorMessage = "Empty string!"; | ||
|
||
const validate = (value: string): string | null | undefined => { | ||
if (value === "") { | ||
if (value === "initials") { | ||
return errorMessage; | ||
} | ||
}; | ||
|
@@ -729,10 +729,10 @@ describe("Required LabeledTextField", () => { | |
"test-labeled-text-field-field", | ||
); | ||
textField.focus(); | ||
await userEvent.clear(textField); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we now clear the error state when the field is cleared, this test case can be updated with an example where we update the input value instead of clear it |
||
await userEvent.type(textField, "s"); | ||
|
||
// Act | ||
textField.blur(); | ||
await textField.blur(); | ||
|
||
// Assert | ||
expect(await screen.findByRole("alert")).toHaveTextContent( | ||
|
This file contains 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
This file contains 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.
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.
Since the values change when the
Select none
/Select all
options are picked, we call theonSelectedValuesChangeValidation
handler