mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
3.79k stars 1.12k forks source link

[TreeView] Use the order in which the items are displayed for type-ahead #12827

Closed flaviendelangle closed 1 week ago

flaviendelangle commented 2 weeks ago

Fixes #12826

Not sure if this is a bug fix or just a behavior change. The current type-ahead was alphabetical, if you have the items ["A3", "A2", "A1"], you focus "A3" and press "a", the focus goes to "A1" because it's the 1st matching item alphabetically. This PR switches for a search based on the displayed order (you focus "A2" because it is the 1st matching item below the currently focused one.

IMHO this is a lot more consistent, it's the approach taken by this TreeView for instance.

Nice side-effect, we no longer generate the list of the 1st letter of every item on each keystroke Now that getNextNavigableItem is cheap it's a lot more efficient that way

Follow up

Add test in #12811

mui-bot commented 2 weeks ago

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

Generated by :no_entry_sign: dangerJS against f4261c391013c474fd9a693b8b7bcbc2a29060f3