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
261 stars 37 forks source link

Allow overriding of "isBranch" state for nodes #162

Closed thoughts3rased closed 8 months ago

thoughts3rased commented 10 months ago

Describe the solution you'd like I would like the ability to override the "isBranch" boolean on nodes to signify that the node is an intended branch with no children.

For example, if you were rendering a directory view of files, you could show empty folders instead of treating them as nodes (or in my case, I chose to hide them if they had no children).

A possible way to do this would be an extra property on each object passed in through the data, maybe something like "isBranch" or a similar property name.

What value does this proposed solution bring to users? Allows greater flexibility for developers and broadens the use cases for this component without having to resort to non-standard ways of implementing this themselves.

Describe alternatives you've considered I have considered adding this tag in the metadata for the data I pass in, however this requires altering the handleSelect and handleExpand methods which isn't ideal for my simple use case. It also would still register the node classnames so styling for this faux-branch would be the same as a normal node.

dgreene1 commented 10 months ago

Are you saying that isBranch will be false even if you have an empty array in it?

Can you try that?

Btw, we’d be open to a feature request for this as long as it meets WCAG 2.1 AA. But since our company does not use a file system branch widget in our products, we don’t have the budget to add this feature ourselves. But we’d take your PR. :)

thoughts3rased commented 10 months ago

From some basic testing, it seems that isBranch stays false even if an empty array is provided as the 'children' property. I could definitely look into implementing this as a feature though as it is a very useful feature to have.

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 8 months ago

This issue was closed automatically since it was marked as stale because it has not had recent activity. Thank you for your contributions.