Skip to content

Commit 2f04e97

Browse files
committed
fix: hide expand all row toggle by default
Signed-off-by: Akshat Patel <[email protected]>
1 parent 28f62e5 commit 2f04e97

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

src/table/head/table-head-expand.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@ import { Observable } from "rxjs";
1313
selector: "[cdsTableHeadExpand], [ibmTableHeadExpand]",
1414
template: `
1515
<button
16+
*ngIf="showExpandAllToggle"
1617
class="cds--table-expand__button"
1718
[attr.aria-label]="getAriaLabel() | async"
1819
(click)="expandedChange.emit(!expanded)">
1920
<svg cdsIcon="chevron--right" size="16" class="cds--table-expand__svg"></svg>
2021
</button>
22+
<ng-container *ngIf="!showExpandAllToggle">
23+
<ng-content></ng-content>
24+
</ng-container>
2125
`
2226
})
2327
export class TableHeadExpand {
2428
@HostBinding("class.cds--table-expand") hostClass = true;
2529

30+
@Input() showExpandAllToggle = false;
31+
2632
@Input() expanded = false;
2733

2834
@Output() expandedChange = new EventEmitter<boolean>();

src/table/head/table-head.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { TableRowSize } from "../table.types";
3131
cdsTableHeadExpand
3232
*ngIf="model.hasExpandableRows()"
3333
scope="col"
34+
[showExpandAllToggle]="showExpandAllToggle"
3435
[ngClass]="{'cds--table-expand-v2': stickyHeader}"
3536
[id]="model.getId('expand')"
3637
[expanded]="model.expandableRowsCount() === model.expandedRowsCount()"
@@ -104,6 +105,8 @@ export class TableHead implements AfterViewInit {
104105

105106
@Input() stickyHeader = false;
106107

108+
@Input() showExpandAllToggle = false;
109+
107110
/**
108111
* Setting sortable to false will disable all headers including headers which are sortable. Is is
109112
* possible to set the sortable state on the header item to disable/enable sorting for only some headers.

src/table/stories/app-expansion-table.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class CustomHeaderItem extends TableHeaderItem {
4545
[striped]="striped"
4646
(sort)="customSort($event)"
4747
(rowClick)="onRowClick($event)"
48-
[isDataGrid]="isDataGrid">
48+
[isDataGrid]="isDataGrid"
49+
[showExpandAllToggle]="showExpandAllToggle">
4950
</cds-table>
5051
5152
<br>
@@ -64,6 +65,7 @@ export class ExpansionTableStory implements AfterViewInit {
6465
@Input() sortable = true;
6566
@Input() stickyHeader = false;
6667
@Input() skeleton = false;
68+
@Input() showExpandAllToggle = false;
6769

6870
@ViewChild("customHeaderTemplate")
6971
protected customHeaderTemplate: TemplateRef<any>;

src/table/table.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ import { TableRowSize } from "./table.types";
197197
[selectAllCheckboxSomeSelected]="selectAllCheckboxSomeSelected"
198198
[showSelectionColumn]="showSelectionColumn"
199199
[enableSingleSelect]="enableSingleSelect"
200+
[showExpandAllToggle]="showExpandAllToggle"
200201
[skeleton]="skeleton"
201202
[sortAscendingLabel]="sortAscendingLabel"
202203
[sortDescendingLabel]="sortDescendingLabel"
@@ -386,6 +387,11 @@ export class Table implements OnInit, AfterViewInit, OnDestroy {
386387

387388
@Input() noBorder = true;
388389

390+
/**
391+
* Set to `true` to show expansion toggle when table consists of row expansions
392+
*/
393+
@Input() showExpandAllToggle = false;
394+
389395
get isDataGrid(): boolean {
390396
return this._isDataGrid;
391397
}

src/table/table.stories.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ const ExpansionTemplate = (args) => ({
482482
[stickyHeader]="stickyHeader"
483483
[skeleton]="skeleton"
484484
[striped]="striped"
485-
[isDataGrid]="isDataGrid">
485+
[isDataGrid]="isDataGrid"
486+
[showExpandAllToggle]="showExpandAllToggle">
486487
</app-expansion-table>
487488
</cds-table-container>
488489
`
@@ -491,7 +492,8 @@ export const WithExpansion = ExpansionTemplate.bind({});
491492
WithExpansion.args = {
492493
...getProps({
493494
description: "With expansion"
494-
}, "args")
495+
}, "args"),
496+
showExpandAllToggle: false
495497
};
496498

497499
const DyanmicContentTemplate = (args) => ({

0 commit comments

Comments
 (0)