Skip to content

[TreeView] useSimpleTreeViewApiRef should expose the actual ref to the root DOM node #20743

@yairEO

Description

@yairEO

Summary

The useSimpleTreeViewApiRef API should expose rootElementRef to get the root DOM node, similarly to what already exist in DataGrid component:

const apiRef = useGridApiContext();
const gridRoot = apiRef.current.rootElementRef?.current;

👉 There is no equivalent for const apiRef = useSimpleTreeViewApiRef();

Examples

No response

Motivation

I need this in order to find & highlight texts using a 3rd-party package react-css-highlight

It is far from ideal to manually create a ref just for that when useSimpleTreeViewApiRef already exists, without any props-drilling required.

Search keywords: tree root element ref

Order ID: 122317


Also, the docs are missing a page for explaining the available properties of the apiRef object returned from useSimpleTreeViewApiRef. Would be helpful...

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: tree viewChanges related to the tree view. This includes TreeView, TreeItem.status: waiting for maintainerThese issues haven't been looked at yet by a maintainer.support: pro standardSupport request from a Pro standard plan user. https://mui.com/legal/technical-support-sla.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions