dgreene1 / react-accessible-treeview

A react component that implements the treeview pattern as described by the WAI-ARIA Authoring Practices.
https://dgreene1.github.io/react-accessible-treeview
MIT License
277 stars 37 forks source link

Add custom properties to element object #53

Closed Sp33ktrE closed 2 years ago

Sp33ktrE commented 2 years ago

Hi, is there a way to add more data to a node object?

dgreene1 commented 2 years ago

We’ll need more information before we can answer your question.

like what would this extra data look like when it is rendered?

please consider providing a visual mock-up and/or a TypeScript interface for your proposal.

before you do, please look at the interface to see if it’s possible. There is a render function that likely does what you need.

Sp33ktrE commented 2 years ago

1) Basically, i want to add more optional data to my node when generating the data tree so i can do conditional styling/behaviour.

type

2) Is there a way to preserve the same node ids when generating a tree using the flattenTree helper function instead of autoincremental ids.

dgreene1 commented 2 years ago

This isn’t a scenario that I or my team has needed so the only answer I can give is “I don’t know.”

I will share that there is a nodeRenderer function on the component for which you can do a lookup within and then conditionally style each node. The lookup (by name or by ID) will allow you to get everything you need.

I don’t have time to code that out right now.

I think it might be best to keep “how to” questions to StackOverflow as issues are for bug fixes or feature requests. And in full transparency, we won’t be taking on feature requests unless they are accessibility related since the current API is flexible enough for almost anything.