-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SingleSelect validation props (#2376)
## Summary: - Adding validation related props to SingleSelect: `validate`, `onValidate`, `required`. (`error` prop was already supported) - DropdownOpener and SelectOpener: Add optional `onBlur` prop and set `aria-invalid` based on `error` prop - DropdownCore: When checking keyboard events, check what key is pressed using [event.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) instead of [event.which](https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/which) or [event.keyCode](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode) which are now deprecated. Testing keyboard interactions in tests weren't triggering the correct logic since we were using deprecated fields that [user-event doesn't support anymore](https://github.com/testing-library/user-event/releases/tag/v14.0.0): > Support for keyCode property on keyboard events has been removed. Next: Will work on applying similar changes to MultiSelect and consolidating any common logic! Issue: WB-1782 ## Test plan: - SingleSelect docs are reviewed `?path=/docs/packages-dropdown-singleselect--docs` - Validation works as expected in SingleSelect (see docs for more details on validation behaviour): - Error `?path=/story/packages-dropdown-singleselect--error` - Required `?path=/story/packages-dropdown-singleselect--required` - Error From Validation `?path=/story/packages-dropdown-singleselect--error-from-validation` - SingleSelect continues to work as expected (including keyboard interactions) Author: beaesguerra Reviewers: beaesguerra, jandrade Required Reviewers: Approved By: jandrade Checks: ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test / Test (ubuntu-latest, 20.x, 2/2), ✅ Test / Test (ubuntu-latest, 20.x, 1/2), ✅ Lint / Lint (ubuntu-latest, 20.x), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Chromatic - Build on regular PRs / chromatic (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ⏭️ Chromatic - Skip on Release PR (changesets), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ gerald, ⏭️ dependabot Pull Request URL: #2376
- Loading branch information
1 parent
c7178e1
commit 71e7086
Showing
11 changed files
with
1,117 additions
and
91 deletions.
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,10 @@ | ||
--- | ||
"@khanacademy/wonder-blocks-dropdown": minor | ||
--- | ||
|
||
# SingleSelect | ||
|
||
- Add `required`, `validate`, and `onValidate` props to support validation. | ||
- DropdownOpener and SelectOpener: | ||
- Add `onBlur` prop | ||
- Set `aria-invalid` if it is in an error state. |
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 | ||
--- | ||
|
||
Update `DropdownCore` to check for key presses using `event.key` instead of `event.which` or `event.keyCode` (which are both deprecated now) |
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
Oops, something went wrong.