Skip to content

Commit 6d5a336

Browse files
committed
working on adding resizable columns when working with sticky columns
1 parent 1482625 commit 6d5a336

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

packages/components/src/components/hds/advanced-table/index.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -196,23 +196,6 @@ export default class HdsAdvancedTable extends Component<HdsAdvancedTableSignatur
196196
onColumnResize,
197197
});
198198

199-
const resizableColumns = columns.filter((column) => column.isResizable);
200-
const resizableColumnLabels = resizableColumns.map(
201-
(column) => column.label
202-
);
203-
204-
if (resizableColumns.length > 0) {
205-
assert(
206-
'Cannot have a sticky first column if there are resizable columns.',
207-
!hasStickyFirstColumn
208-
);
209-
210-
assert(
211-
`Cannot have resizable columns if there are nested rows. Resizable columns are ${resizableColumnLabels.toString()}`,
212-
!this._tableModel.hasRowsWithChildren
213-
);
214-
}
215-
216199
if (this._tableModel.hasRowsWithChildren) {
217200
const sortableColumns = columns.filter((column) => column.isSortable);
218201
const sortableColumnLabels = sortableColumns.map(
@@ -228,6 +211,16 @@ export default class HdsAdvancedTable extends Component<HdsAdvancedTableSignatur
228211
'Cannot have a sticky first column if there are nested rows.',
229212
!hasStickyFirstColumn
230213
);
214+
215+
const resizableColumns = columns.filter((column) => column.isResizable);
216+
const resizableColumnLabels = resizableColumns.map(
217+
(column) => column.label
218+
);
219+
220+
assert(
221+
`Cannot have resizable columns if there are nested rows. Resizable columns are ${resizableColumnLabels.toString()}`,
222+
resizableColumns.length === 0
223+
);
231224
}
232225
}
233226

showcase/app/components/mock/app/main/generic-advanced-table.gts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,22 @@ const SAMPLE_COLUMNS = [
3333
label: 'Project name',
3434
key: 'project-name',
3535
isSortable: true,
36-
width: 'max-content',
36+
isResizable: true,
37+
width: '300px',
3738
},
3839
{
3940
label: 'Current run ID',
4041
key: 'current-run-id',
4142
isSortable: true,
42-
width: 'max-content',
43+
isResizable: true,
44+
width: '300px',
4345
},
4446
{
4547
label: 'Run status',
4648
key: 'run-status',
4749
isSortable: true,
48-
width: 'max-content',
50+
isResizable: true,
51+
width: '200px',
4952
},
5053
{
5154
label: 'Current run applied',

0 commit comments

Comments
 (0)