CHARTS-18: Allow keyboard navigation for the bar chart
Fixes CHARTS-18
Proposed changes:
- Convert the accessibility layer from the line chart to a separate component and hook to make it reusable
- Use the new tooltip component and the hook for the bar chart
https://github.com/user-attachments/assets/8dc23e6d-f9c4-49f3-ac59-15953b2c4019
Other information:
- [x] Have you written new tests for your changes, if applicable?
- [x] Have you checked the E2E test CI results, and verified that your changes do not break them?
- [x] Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?
Jetpack product discussion
N/A
Does this pull request change what data or activity we track or use?
No
Testing instructions:
- Start the storybook per steps in the charts library - https://github.com/Automattic/jetpack/tree/27d5924896c6c4cfabded89fa1b6247aaefd2e55/projects/js-packages/charts#storybook
- Run any bar chart storybook with tooltip and start navigating with keyboard, The tooltips should be displayed.
- First click tab to focus the bar chart and use keyboard to navigate between data points on the chart
- Use VoiceOver in Mac (or any other screenreader tool) to test how screen readers announce the contents of the tooltips
Thank you for your PR!
When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
- :white_check_mark: Include a description of your PR changes.
- :white_check_mark: Add a "[Status]" label (In Progress, Needs Review, ...).
- :white_check_mark: Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
- :white_check_mark: Add testing instructions.
- :white_check_mark: Specify whether this PR includes any changes to data or privacy.
- :white_check_mark: Add changelog entries to affected projects
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 :robot:
Follow this PR Review Process:
- Ensure all required checks appearing at the bottom of this PR are passing.
- Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
- You can use GitHub's Reviewers functionality to request a review.
- When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.
If you have questions about anything, reach out in #jetpack-developers for guidance!
Code Coverage Summary
Coverage changed in 2 files.
| File | Coverage | Δ% | Δ Uncovered |
|---|---|---|---|
| projects/js-packages/charts/src/components/bar-chart/bar-chart.tsx | 68/73 (93.15%) | 4.26% | -1 💚 |
| projects/js-packages/charts/src/components/line-chart/line-chart.tsx | 77/82 (93.90%) | 5.27% | -10 💚 |
1 file is newly checked for coverage.
| File | Coverage |
|---|---|
| projects/js-packages/charts/src/components/tooltip/accessible-tooltip.tsx | 58/68 (85.29%) 💚 |
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
- To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the
charts-18-bar-chart-keyboard-navigationbranch. - To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack charts-18-bar-chart-keyboard-navigation
Interested in more tips and information?
- In your local development environment, use the
jetpack rsynccommand to sync your changes to a WoA dev blog. - Read more about our development workflow here: PCYsg-eg0-p2
- Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2
Known issue: For series with missing points of data, it jumps to the next one. The same happens for tooltips, please see video below:
https://github.com/user-attachments/assets/96ba65eb-ed5b-4404-a77e-20402a5bc71b