Skip to content

[question][tree view] Adding a test id to a RichTreeViewPro item #21817

Description

@sydneyjodon-wk

The problem in depth

Hello 👋

I'm trying to add a data-testid to the items of a RichTreeViewPro, but running into type errors:

<RichTreeViewPro
    items={ITEMS}
    slotProps={{
      item: ( item ) => ({
        'data-testid': item.itemId,
      }),
    }}
/>

The above code works, but has a type error on item because data-testid isn't a part of TreeItemProps

Image

Is there a better way to add a test id to RichTreeViewPro items or would it be possible to expand the typing on slotProps.item so that it can be added there without type issues?

Thank you!

Your environment

See codesandbox: https://stackblitz.com/edit/m14vsgsd?file=src%2FDemo.tsx

Search keywords: RichTreeView test id item

Order ID: 82849

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: tree viewChanges related to the tree view. This includes TreeView, TreeItem.support: premium standardSupport request from a Premium 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