feat(tabletools): add collapse all option for the table - #127
Conversation
c7c2259 to
b583276
Compare
|
@Fewwy Thank you for taking the time to add this! It would be great if we'd have this also in the Storybook. It should be enough to extend the |
| ...(enableExpandingRow | ||
| ? { | ||
| tableProps: { | ||
| canCollapseAll: options.canCollapseAll !== false, |
There was a problem hiding this comment.
Since the useExpandable is also utilised when the table is a tree, we do need to add one guard here to not pass the canCollapseAll prop in that case.
Something like:
...!options.treeTable ? { canCollapseAll: options.canCollapseAll !== false,} : {}We could at some point extend the "expand all" feature to support tree tables, but that will require a bit more work... and might actually be tricky to implement.
There was a problem hiding this comment.
I added it :) thank for the advice
There was a problem hiding this comment.
@Fewwy Mind taking another look. I was really just guessing.... It seems that the when a treetable is passed it still shows the collapse all:

I am working on migrating Rules table in Advisor to tabletools, and I stumbled upon the fact that tabletools does not handle expand all rows.
Right now useExpandable only exposes single-row toggle: ({ item: { itemId } }) => toggle(itemId). It never passes canCollapseAll: true to PF's Table, so the expand-all arrow never renders
What this pr change
useExpandable now handles the PF Table's canCollapseAll pattern:
When detailsComponent is set, canCollapseAll: true is automatically passed to the Table — renders the expand-all chevron in the header row.
onCollapse handles rowIndex === undefined (PF's expand-all signal) using set/clear from useSelectionManager
useTableTools passes items to useExpandable so it knows which itemIds to expand