-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accessibility and Usability Enhancements for Explanation Widget (#1060)
## Summary: The Explanation widget should be consistent regardless of its content type, as well as across device platforms. Therefore, the `<Clickable>` element is now changed to a Wonder Blocks `<Button>`. Additionally, minor custom formatting that was tied to the content type (i.e. article) or the platform (i.e. mobile) has been removed. The widget should also follow accessibility best practices. The attribute `aria-controls` has been added to the button to indicate what will be affected when it is toggled. Although [this attribute is not currently being used](w3c/aria#995) by assistive technologies, it is [highly recommended by the ARIA working group](w3c/aria#995 (comment)) that this attribute be applied in cases such as this. Therefore, in addition to the attribute being added to the button, the content that is shown/hidden by the button is now rendered in the DOM at all times in order to be referenced by the `aria-controls` attribute. Interactions with the widget should respond in an intuitive manner. When activation of an element causes something else to happen on the page, an [animation can ease the cognitive aspects](https://www.nngroup.com/articles/animation-usability/) of following that change. Therefore, CSS transitions have been applied to properties of the content wrapper to change the show/hide action to be a reveal/conceal action (see the Before and After videos for a comparison). In order to honor the preferences of the user, the widget checks the `prefers-reduced-motion` media preference before applying the transitions. Other interesting changes: * Refactored the widget to take advantage of the common visuals across use cases. * Removed unneeded logic branches. * Removed unneeded styling. * Removed unneeded unit tests. * Moved styling logic outside of the JSX block. * Added a new Storybook story (with new test data) to show a normal use case. * Fixed unit tests for Graded Group widget which improperly referenced the Explanation widget. * Changed the test data to use the GG widget's internal Explain/Hide button. * Updated the snapshots. * Added UI regression tests to guard against CSS mishaps that alter keyboard interactions. Issues: LP-5838, LEMS-199, LEMS-259, LP-11557 (possibly), LEMS-277, LC-212, MOB-5434 (possibly) ## Test plan: 1. Open the Perseus Storybook (locally: http://localhost:6006/?path=/story/perseus-widgets-explanation--question-1). * Notice the change in appearance of the "Explanation" button. 1. Activate the "Explanation" button (either by clicking it or by tabbing to it and pressing Enter/Spacebar keys). * Notice that the widget content is revealed via an animation. * Activating the button (now showing "Hide") again causes the content to be concealed, but slightly faster than when it is revealed. 1. Change your accessibility settings to prefer reduced motion. * In MacOS, open System Settings => Accessibility => Display => Reduce motion 1. Activate the "Explanation" button again. * Notice that the widget content is shown without any animation. * Don't forget to reset your accessibility settings. ## Affected Behavior: ### Before - Current UX https://github.com/Khan/perseus/assets/13896410/dcb1fcdc-c4cd-4e01-b342-e4a7f39ba583 ### After - New UX https://github.com/Khan/perseus/assets/13896410/a8622fba-c61e-4107-9a87-80fe1f6829bb Author: mark-fitzgerald Reviewers: jeremywiebe, benchristel, mark-fitzgerald Required Reviewers: Approved By: jeremywiebe Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage, ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Extract i18n strings (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ gerald, ✅ Jest Coverage (ubuntu-latest, 20.x) Pull Request URL: #1060
- Loading branch information
1 parent
113a6ac
commit 857ea95
Showing
15 changed files
with
503 additions
and
694 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,5 @@ | ||
--- | ||
"@khanacademy/perseus": minor | ||
--- | ||
|
||
Accessibility and Usability Enhancements for Explanation Widget |
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
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.