[Simple Analytics] Accessibility#214
Conversation
|
@alaca thanks for the PR! Could you please fill out the PR template with description, changelog, and credits information so that we can properly review and merge this? |
There was a problem hiding this comment.
Pull request overview
Adds accessibility improvements to the Simple Analytics admin page, focusing on keyboard interaction, chart alternatives, reduced motion, and contrast.
Changes:
- Updates date range controls with ARIA labeling, dialog semantics, and Escape handling.
- Adds reduced-motion Chart.js configuration and screen-reader chart data tables.
- Adjusts focus indicators, chart colors, and muted-state contrast.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
includes/admin/templates/analytics.php |
Adds ARIA attributes and hidden data-table containers for analytics charts. |
assets/js/analytics.js |
Adds reduced-motion handling, Escape popover behavior, chart color updates, and dynamic data-table rendering. |
assets/css/analytics.scss |
Adds screen-reader utility styles, updated focus-visible rings, contrast tweaks, and reduced-motion CSS. |
Comments suppressed due to low confidence (4)
assets/js/analytics.js:1353
- The screen-reader table is only populated on the ready path and is never cleared by the loading, empty, or error paths. After a successful load, changing filters to an empty range or failed request leaves stale rows in the element referenced by aria-describedby, so assistive technology can still receive the previous chart data.
renderDataTable(rows, fromLabel, toLabel);
assets/js/analytics.js:531
- The new screen-reader table rendering is not covered by the existing analytics Cypress success-state tests. Those tests already stub chart payloads, so they should assert that the aria-describedby target contains a table with the expected row data after a successful response.
function renderDataTable(rows, fromLabel, toLabel) {
assets/js/analytics.js:1044
- The new screen-reader table rendering is not covered by the existing analytics Cypress success-state tests. Those tests already stub chart payloads, so they should assert that the aria-describedby target contains a table with the expected row data after a successful response.
function renderDataTable(rows, fromLabel, toLabel) {
includes/admin/templates/analytics.php:380
- The chart still exposes tooltip details only through Chart.js pointer interactions: the canvas is not focusable and there are no keyboard handlers for moving between data points. The hidden table helps screen-reader users, but sighted keyboard users still cannot access the per-bucket tooltip values required for keyboard-accessible chart tooltips.
class="mailchimp-sf-sa__canvas"
role="img"
aria-label="<?php esc_attr_e( 'Subscriber change bar chart', 'mailchimp' ); ?>"
aria-describedby="mailchimp-sf-sa-data-table"
></canvas>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| setOverlay(''); | ||
| setState('ready'); | ||
| renderChart(rows); | ||
| renderDataTable(rows, fromLabel, toLabel); |
| <div | ||
| id="mailchimp-sf-sa-data-table" | ||
| class="mailchimp-sf-sa__data-table screen-reader-text" |
| .mailchimp_page_mailchimp_sf_analytics .mailchimp-sf-button:focus-visible, | ||
| .mailchimp_page_mailchimp_sf_analytics button:focus-visible { | ||
| box-shadow: 0 0 0 2px var(--mailchimp-color-link, #017e89); | ||
| outline: none; |
| class="mailchimp-sf-fp__canvas" | ||
| role="img" | ||
| aria-label="<?php esc_attr_e( 'Form views, submissions, and conversion rate chart', 'mailchimp' ); ?>" | ||
| aria-describedby="mailchimp-sf-fp-data-table" | ||
| ></canvas> |
There was a problem hiding this comment.
@alaca Could you please check if this is feasible?
| closePopover(); | ||
| if (trigger) { | ||
| trigger.focus(); | ||
| } |
iamdharmesh
left a comment
There was a problem hiding this comment.
Thanks @alaca. Over all this looks good. Could you please check on the feedback from copilot, specifically for keyboard-navigable tooltips? Thank you.
| // while keeping it readable by assistive tech. Defined locally so the | ||
| // styles still apply if WP core's stylesheet load order changes. | ||
| // ----------------------------------------------------------------------------- | ||
| .screen-reader-text { |
There was a problem hiding this comment.
Can we scope this to make sure it only apply to screen reader text added by us?
Something like .mailchimp_page_mailchimp_sf_analytics .screen-reader-text
| class="mailchimp-sf-fp__canvas" | ||
| role="img" | ||
| aria-label="<?php esc_attr_e( 'Form views, submissions, and conversion rate chart', 'mailchimp' ); ?>" | ||
| aria-describedby="mailchimp-sf-fp-data-table" | ||
| ></canvas> |
There was a problem hiding this comment.
@alaca Could you please check if this is feasible?
Description of the Change
Closes #208
How to test the Change
Run Lighthouse Accessibility audit in DevTools. Expect score 100.
Tab through the page. Every control shows a 2px teal ring.
Open date popover. Press Esc. Popover closes, focus returns to trigger.
DevTools Rendering panel, toggle prefers-reduced-motion: reduce. Charts snap, no animation, skeleton pulse frozen.
DevTools Elements, find #mailchimp-sf-fp-data-table and #mailchimp-sf-sa-data-table. Each contains a real table with chart data.
Changelog Entry
Credits
Props @alaca
Checklist: