Skip to content

[charts] Show axis tooltip when navigating with keyboard#21689

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/add-axis-tooltip-keyboard-navigation
Draft

[charts] Show axis tooltip when navigating with keyboard#21689
Copilot wants to merge 4 commits intomasterfrom
copilot/add-axis-tooltip-keyboard-navigation

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

When using trigger="axis" tooltip, keyboard navigation did not trigger the tooltip — only pointer interaction did. The item tooltip (trigger="item") already supported keyboard navigation via selectorChartsTooltipItem switching on lastInteraction === 'keyboard', but the axis tooltip selectors had no equivalent path.

Changes

  • useChartCartesianTooltip.selectors.ts: Added keyboard-aware branching to selectorChartsInteractionTooltipXAxes and selectorChartsInteractionTooltipYAxes. When lastInteraction === 'keyboard', the selectors now use selectorChartsKeyboardXAxisIndex/selectorChartsKeyboardYAxisIndex to derive the axis data index from the focused item, instead of the pointer position. The triggerTooltip flag is still respected.

  • Extracted a shared getKeyboardAxisTooltip helper to avoid duplicating the keyboard branch logic across X and Y selectors.

  • contentDisplayed.test.tsx: Added browser test verifying that keyboard navigation (ArrowRight) displays the correct axis tooltip content when trigger="axis" is set.

<BarChart
  series={[...]}
  enableKeyboardNavigation
  slotProps={{ tooltip: { trigger: 'axis' } }}
/>
// Arrow key navigation now shows axis tooltip for the focused data index

This follows the same pattern already used in useChartCartesianHighlight.selectors.ts, which already combined pointer and keyboard axis indices for axis highlight behavior.

Original prompt

This section details on the original issue you should resolve

<issue_title>[charts] Show axis tooltip when navigating with keyboard</issue_title>
<issue_description>### Summary

When moving focus with keyboard, the tooltip follows the focused item. Similar behavior should be done with tooltip trigger="axis"

Examples

No response

Motivation

No response

Search keywords: a11y, keyboard, tooltip</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Modify selectorChartsInteractionTooltipXAxes and selectorChartsInteractionTooltipYAxes
to support keyboard navigation by checking lastInteraction and using the focused item's
axis index when lastInteraction === 'keyboard'.

Co-authored-by: alexfauquette <45398769+alexfauquette@users.noreply.github.com>
@mui-bot
Copy link

mui-bot commented Mar 10, 2026

Deploy preview: https://deploy-preview-21689--material-ui-x.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 🔺+149B(+0.04%) 🔺+54B(+0.05%)
@mui/x-charts-pro 🔺+149B(+0.03%) 🔺+66B(+0.05%)
@mui/x-charts-premium 🔺+149B(+0.03%) 🔺+61B(+0.04%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against cb8a2ba

Copilot AI and others added 2 commits March 10, 2026 11:57
Co-authored-by: alexfauquette <45398769+alexfauquette@users.noreply.github.com>
Co-authored-by: alexfauquette <45398769+alexfauquette@users.noreply.github.com>
Copilot AI changed the title [WIP] Add axis tooltip for keyboard navigation in charts [charts] Show axis tooltip when navigating with keyboard Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[charts] Show axis tooltip when navigating with keyboard

3 participants