-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TreeView] Add utility function to check if an optional plugin is present #13788
Conversation
@@ -0,0 +1,12 @@ | |||
import { TreeViewAnyPluginSignature, TreeViewInstance, TreeViewPlugin } from '../models'; | |||
|
|||
export const hasPlugin = < |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't have this inside useTreeViewOptionalPlugins
because instance
needs to be a param in order to infer its shape.
Otherwise we would need to do instance.hasPlugin(instance, plugin)
which is worse IMHO.
@@ -142,7 +143,9 @@ export const useTreeViewKeyboardNavigation: TreeViewPlugin< | |||
const nextItem = getNextNavigableItem(instance, itemId); | |||
if (nextItem) { | |||
event.preventDefault(); | |||
instance.focusItem(event, nextItem); | |||
if (hasPlugin(instance, useTreeViewFocus)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used this plugin as an example but I will remove before merging 👌
Deploy preview: https://deploy-preview-13788--material-ui-x.netlify.app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was so fast⚡
LGTM 🐈⬛
Closes #13777