Charts: shared keyboard-nav fixes — ARIA grid boundaries + index-space alignment#50140
Draft
adamwoodnz wants to merge 2 commits into
Draft
Charts: shared keyboard-nav fixes — ARIA grid boundaries + index-space alignment#50140adamwoodnz wants to merge 2 commits into
adamwoodnz wants to merge 2 commits into
Conversation
At the ends of a chart's data, arrow keys now keep focus on the boundary cell instead of escaping (ArrowRight on the last point) or wrapping (ArrowLeft on the first point), matching the WAI-ARIA grid pattern the widget already advertises via role="grid". This keeps the highlight/tooltip visible at both ends and makes the two directions symmetric.
Derive the keyboard navigation totalPoints from primaryEntries (filtered by both comparison type and visibility) so keyboard nav, the accessible tooltip, and the highlight CSS all stride over the identical series list. Previously totalPoints counted comparison-filtered series only, so hiding a primary series via an interactive legend left keyboard nav visiting blank slots with no datum and no highlight.
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCannot generate coverage summary while tests are failing. 🤐 Please fix the tests, or re-run the Code coverage job if it was something being flaky. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two related fixes in the shared
useKeyboardNavigationhook / bar-chart keyboard path, surfaced while reviewing #49959 (CHARTS-220 follow-up). Both are general charts-library behaviour (not comparison-specific) and affect all chart types, so they were kept out of CHARTS-220 and given their own tests.Proposed changes
gridboundary convention (stop, don't escape). The charts advertiserole="grid", but arrow keys behaved asymmetrically at the ends:ArrowRighton the last point escaped focus back to the container (the highlight/tooltip vanished), whileArrowLefton the first point wrapped to the last. Per the WAI-ARIA APG grid pattern, focus does not move at a boundary. NowArrowRighton the last point stays on the last point andArrowLefton the first point stays on the first point — the highlight/tooltip remains visible and both directions are symmetric. Exiting still happens via Tab (returns focus to the container) and Escape (clears). (accessible-tooltip.tsx)selectedIndexback to a bar and must stride over the same series list.totalPointswas derived from a comparison-only filtered list, while the tooltip/highlight used a list filtered by both comparison type and visibility. When an interactive legend hid a primary series,totalPointskept counting the hidden one, soselectedIndexcould reach slots that resolved to no datum and no highlight (blank stops).totalPointsis now derived fromprimaryEntries(visibility- and comparison-filtered), so all three index spaces agree. This also closes the latent seam for standard (non-comparison) interactive-legend charts. (bar-chart.tsx)Because both changes live in the shared keyboard-nav path, they affect all chart types (line, bar, area…). Hidden series' slots are no longer visited on any interactive-legend chart.
Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
Automated:
jp test js js-packages/charts— all suites pass (969 tests). New tests were added tosrc/charts/bar-chart/test/bar-chart.test.tsx:ArrowRightat the last point stays put and keeps the highlight (no escape, no wrap);ArrowLeftat the first point stays put (no wrap).Manual (Storybook → Bar Chart → Comparison story, 5 nav stops Mon–Fri):
role="grid").Boundary clamping demonstrated end-to-end in the browser (verified with an expert visual review):
Right boundary — highlight/tooltip stays clamped on the last bar (Fri) after extra Right presses:
Left boundary — highlight/tooltip stays clamped on the first bar (Mon) after extra Left presses:
Linear Issue: CHARTS-221