-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
During playtesting, Sarah B pointed out that the tab order for segment graphs was not very intuitive. Tabbing to a segment first selected the whole segment. Tabbing further selected each endpoint. This PR updates the tab order so the first endpoint is selected first, then the segment, then the second endpoint. There are some interesting constraints on the implementation of this feature: - SVG elements are always painted in document order: SVG has no equivalent of z-index. We want the line of a movable segment to render behind the points. That means the line element *must* be first. - Unfortunately, that leaves us with very few options for customizing the tab order. Setting `tabindex` > 0 is not what we want, since it would bump the movable points to the very front of the tab order for the entire page. The solution is as follows: - Add some focusable, invisible `<g>` elements to stand in for the points, since we cannot reorder the points relative to the line. - Hook up `useMovable` to those elements, so focusing them lets you move the points with arrow keys. - Disable tabbing to the points themselves. - Display a focus ring on a point if you have focused its corresponding `<g>`. I split the StyledMovablePoint component into two: there is now a MovablePointView component that is purely presentational, and has no state or `useMovable`. This component has two modes for managing focus. You can either set a `tabindex` and let the component itself be focusable, or you can pass a boolean that tells the component whether it should have a focus ring. Issue: LEMS-1936 ## Test plan: View a Mafs segment graph in the dev ui (`yarn dev`). Tabbing between UI elements should feel intuitive. https://github.com/Khan/perseus/assets/693920/ee92b81b-5f01-44d3-942a-b9d80c74ee9e Author: benchristel Reviewers: benchristel, nishasy, #perseus, handeyeco, mark-fitzgerald Required Reviewers: Approved By: nishasy Checks: ✅ codecov/project, ✅ codecov/patch, ✅ Upload Coverage, ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Jest Coverage (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: #1240
- Loading branch information
1 parent
99f32f5
commit 4a59b85
Showing
20 changed files
with
613 additions
and
317 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": patch | ||
--- | ||
|
||
Change the tab order for movable line segments in interactive graphs. Previously, the order was `(whole segment, first point, second point)`. Now it's `(first point, whole segment, second point)`, which aligns better with the visual layout of the graph. |
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/perseus": patch | ||
"@khanacademy/perseus-editor": patch | ||
--- | ||
|
||
Adjust spacing in locked point and locked line settings |
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.