Skip to content

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Sep 19, 2025

Follow up on keyboard navigation

The idea is to use the keyboard interaction state for highlight if the state is not controlled.
By priority, we show:

  1. the controlled value
  2. the keyboard navigation value
  3. the pointer interaction value

https://deploy-preview-19631--material-ui-x.netlify.app/x/react-charts/accessibility/#keyboard-support

Capture.video.du.2025-09-19.15-36-50.mp4

To do in a follow up: update the same way the item highlight

@alexfauquette alexfauquette added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. scope: charts Changes related to the charts. labels Sep 19, 2025
@mui-bot
Copy link

mui-bot commented Sep 19, 2025

Deploy preview: https://deploy-preview-19631--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 🔺+690B(+0.21%) 🔺+271B(+0.27%)
@mui/x-charts-pro 🔺+690B(+0.16%) 🔺+257B(+0.19%)
@mui/x-charts-premium 🔺+690B(+0.16%) 🔺+243B(+0.18%)
@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 0c340d5

Copy link

codspeed-hq bot commented Sep 19, 2025

CodSpeed Instrumentation Performance Report

Merging #19631 will not alter performance

Comparing alexfauquette:keyboard-highlight (0c340d5) with master (e1cf0f9)1

Summary

✅ 12 untouched

Footnotes

  1. No successful run was found on master (217a73c) during the generation of this report, so e1cf0f9 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Member

@JCQuintas JCQuintas left a comment

Choose a reason for hiding this comment

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

These changes broke regular axis highlighting. Also, should the "keyboard" highlight only trigger when the highlight options are enabled?

@alexfauquette
Copy link
Member Author

These changes broke regular axis highlighting.

Thanks for the heads up. It's probably just because I returned an empty array instead of undefined

@JCQuintas
Copy link
Member

Should it respect the last changed value? It feels odd that the keyboard always has preference.

Screen.Recording.2025-09-20.at.17.30.13.mov

@alexfauquette
Copy link
Member Author

An other approach could be to update the axis highlight during keyboard interaction. Something like calling instance.setAxisHiglight while pressing keyboard.

@JCQuintas
Copy link
Member

An other approach could be to update the axis highlight during keyboard interaction. Something like calling instance.setAxisHiglight while pressing keyboard.

I think it might work better than current 🤔

@alexfauquette
Copy link
Member Author

It was trickier than expected. The axis highlight only store the pointer coordinate. We did that such that the axis-highlight sty in sync with any axis update.

The new approach store in the state a value pointer | keyboard. This value indicates which interaction is the last one to get an update.

We then have selectors for all options (controlled, pointer, keyboard) and a final selector will pick the correct one

return undefined;
}

let axisId: AxisId | false | undefined = 'xAxisId' in seriesConfig && seriesConfig.xAxisId;
Copy link
Member

Choose a reason for hiding this comment

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

Do we always want to use the x axis here, even if we're running the selectorChartsKeyboardYAxisIndex selector?

Copy link
Member Author

Choose a reason for hiding this comment

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

😭

…tKeyboardNavigation/useChartKeyboardNavigation.ts

Co-authored-by: Bernardo Belchior <[email protected]>
Signed-off-by: Alexandre Fauquette <[email protected]>
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Sep 29, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Sep 29, 2025
Copy link
Member

@JCQuintas JCQuintas left a comment

Choose a reason for hiding this comment

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

I'm curious if users will want to have the last hover highlight to be the start of the keyboard highlight.

Should be good for now though

@JCQuintas
Copy link
Member

Btw the accessibility page is not on the sidebar, was that intentional? 🤔

@alexfauquette
Copy link
Member Author

Btw the accessibility page is not on the sidebar, was that intentional? 🤔

Yes, I'm planning to add it when keyboard navigation is done. Not an issue if user find the page, but I prefer to wait a bit before advertising it

@alexfauquette alexfauquette enabled auto-merge (squash) September 30, 2025 07:29
@alexfauquette alexfauquette merged commit 943e431 into mui:master Sep 30, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: charts Changes related to the charts. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants