Skip to content

Conversation

walterra
Copy link
Contributor

@walterra walterra commented Aug 11, 2025

Summary

In general Elastic Charts has strict separation of concerns and individual charts are not aware of each other. How screen reader summaries were created was a bit of an exemption with chart type checks and customization within the screen reader components. To prepare for more detailed screen reader descriptions for individual charts, this PR adds an optional getScreenReaderDataselector to the chart selector factories. This allows to create individual chart descriptions using a generic shared screen reader component instead of the current hard coded logic.

Details

  • Moved chart type-specific screen reader data generation to dedicated selectors using the ChartSelectors pattern
  • Introduces ChartLabelData interface to make screen reader components chart-agnostic (used by the goal chart)
  • Replaced div wrappers with semantic HTML elements like figcaption
  • Fixed invalid HTML by moving screen reader elements outside canvas elements

Refactoring examples:

  • packages/charts/src/components/accessibility/screen_reader_summary.tsx no longer includes chart specific logic (like goalChartData). Instead this can be now found in the chart specific selector in packages/charts/src/chart_types/goal_chart/state/selectors/get_screen_reader_data.ts.
  • The ScreenReaderPartitionTable (specific to the partition chart) was moved from the common accessbility directory to a chart specific place in partition_chart.

Note: Now that we have baseline e2e a11y tests on CI, we can make a refactor like this with more confidence. The PR passes CI without any updates necessary to the a11y assertions.

Screencast of Safari with A11Y VoiceOver on a basic line chart with current description:

a11y-elastic-charts-0001.mp4

Issues

Part of elastic/kibana#36386.

Checklist

  • All related issues have been linked (i.e. closes #123, fixes #123)
  • Unit tests have been added or updated to match the most common scenarios

@walterra walterra self-assigned this Aug 11, 2025
@walterra walterra added the :accessibility Accessibility related issue label Aug 11, 2025
@walterra walterra force-pushed the a11y-refactor-screen-reader-descriptions branch from ffdc472 to a71cbe3 Compare August 11, 2025 20:28
@walterra walterra marked this pull request as ready for review August 12, 2025 20:34
@walterra walterra changed the title chore(refactor): refactors A11y screen reader description generation into chart selector factories chore(refactor): refactors A11Y screen reader description generation into chart selector factories Sep 10, 2025
Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good to me! Thanks now goal chart is more readable

@walterra walterra merged commit cfd2ce0 into elastic:main Sep 15, 2025
16 checks passed
@walterra walterra deleted the a11y-refactor-screen-reader-descriptions branch September 15, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:accessibility Accessibility related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants