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/
4.34k stars 1.3k forks source link

[TreeView] Add prop to disable type-ahead focusing #14985

Open ohmsl opened 2 weeks ago

ohmsl commented 2 weeks ago

Expected Behaviour

<SimpleTreeView disableTypeAheadFocusing>
     <TreeItem
      itemId={id}
      label={label}
     />
</SimpleTreeView>

Temporary Workaround

This simple workaround works, but it also disables more useful keyboard navigation like the arrow keys.

<SimpleTreeView onKeyDownCapture={(e) => e.stopPropagation()}>
     <TreeItem
      itemId={id}
      label={label}
     />
</SimpleTreeView>

Search keywords: type ahead, focusing, single character

flaviendelangle commented 2 weeks ago

Hi Thanks for your issue.

You can use event.defaultMuiPrevented = true to only prevent the MUI logic without totally stopping the propagation. The following example should keep all the other keyboard interactions.

I'm keeping this issue with "Waiting for upvote" for a built-in support. And I will fire a pull request to make MuiCancellableEventHandler which I uses in this example public :+1:

ohmsl commented 2 weeks ago

Thank you Flavien 🙏🏼