constantin-p / cp-react-tree-table

A fast, efficient tree table component for ReactJS.
https://constantin.software/cp-react-tree-table
MIT License
94 stars 27 forks source link

HasChildrenVisible from v0.* removed in v1 #28

Closed robmim closed 4 years ago

robmim commented 4 years ago

Is there any way to know if a row has children visible in v1 ?

I want to boost the ui/ux by changing this black triangle used to mark rows with childrens but i'm stock simply because i can't know if it is expanded or not.

Am i missing something ?

robmim commented 4 years ago

Implementing ARIA in this component would be a great feature. You can check Table Tree from atlaskit for example. Using aria-expanded="true/false" this way i could at least apply style on the button based on the value of this attribute. ;)

https://atlaskit.atlassian.com/packages/design-system/table-tree

We can't use this component from Atlaskit because of performance issues. Having this feature on your would be awesome.

constantin-p commented 4 years ago

Hi @robmim,

I've just released a new version which introduces isExpanded as a property on the RowState object.

You can now access the expanded/collapsed state of a node inside the cell renderer through row.$state.isExpanded:

  ...

  renderCell = (row) => {
    return (
      <button
        onClick={row.toggleChildren}
        disabled={!row.metadata.hasChildren}>

        {row.$state.isExpanded ? '-' : '+'}
        {row.data.name}
      </button>
    );
  }

  ...

You can take a look at this JSFiddle for a full demo.

robmim commented 4 years ago

I can't thank you enough. This little piece of code give so much more value to your component. Great job by the way ;)