-
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
base: main
Are you sure you want to change the base?
Conversation
… "Select all" shortcuts are used
… error when the field is cleared (including when using the clear button in the SearchField or backspacing the value until it's clear)
…ic value instead of an empty field since errors are cleared for empty fields
…r textfield, textarea, and searchfield
…ld: Clear error state when field is cleared and it is not required
🦋 Changeset detectedLatest commit: d8e0485 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Change: +79 B (+0.08%) Total Size: 96.5 kB
ℹ️ View Unchanged
|
A new build was pushed to Chromatic! 🚀https://5e1bf4b385e3fb0020b7073c-tkfbjwqcmt.chromatic.com/ Chromatic results:
|
@@ -357,10 +357,12 @@ const MultiSelect = (props: Props) => { | |||
.filter((option) => !!option && !option.props.disabled) | |||
.map((option) => option.props.value); | |||
onChange(selected); | |||
onSelectedValuesChangeValidation(); |
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 the onSelectedValuesChangeValidation
handler
@@ -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 comment
The 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
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
npm Snapshot: Published🎉 Good news!! We've packaged up the latest commit from this PR (5018e91) and published all packages with changesets to npm. You can install the packages in webapp by running: ./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2424" Packages can also be installed manually by running: yarn add @khanacademy/wonder-blocks-<package-name>@PR2424 |
Summary:
Previously, if a MultiSelect component had shortcuts enabled, if it was in an error state, the "select all" and "select none" options do not clear the error state. Changing the selected values using these shortcuts now clear the error.
Similarly, if a SearchField component was in an error state, if it is cleared using the clear button, the error would persist. This has been fixed and clearing the value (using the clear button or by erasing the inputted value) now clears the error.
The TextField and TextArea components also clear the error state when the value is cleared, assuming the field is not required.
Issue: WB-1846
Test plan:
MultiSelect
Select none
?path=/story/packages-dropdown-multiselect--error-from-validation
and confirm that the shortcuts control is enabledSelect all
?path=/story/packages-dropdown-multiselect--error-from-validation
and confirm that the shortcuts control is enabledSearchField
?path=/story/packages-searchfield--validation
TextField
?path=/story/packages-form-textfield--instant-validation
TextArea
Same as TextField steps except navigate to
?path=/story/packages-form-textarea--instant-validation