Skip to content

AdvancedTable - Column resizing #2849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 89 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
e1fcc53
added column model
zamoore May 1, 2025
c64cbb9
column resizing works
zamoore May 1, 2025
f4c9f05
resize handle extends to full height of table
zamoore May 2, 2025
2a22650
adding a11y improvements
zamoore May 2, 2025
6bced8a
a11y enhancements
zamoore May 5, 2025
ca8309b
comleted inital styling on range input
zamoore May 5, 2025
e55a36f
resizing columns works with both the slider and the column border
zamoore May 7, 2025
1f6e7d7
requiring widths for resize
zamoore May 7, 2025
28d57f0
reset width works
zamoore May 7, 2025
38bf40a
column resize in progress
zamoore May 9, 2025
a92d46f
calculating percentage based on table width
zamoore May 9, 2025
f55add4
mixed unit math works
zamoore May 9, 2025
5ee0d24
cleaned up the column model
zamoore May 9, 2025
404bb47
correctly works with pixel vals
zamoore May 12, 2025
c6621f2
cleaning up
zamoore May 13, 2025
9c3f21f
simplified the th api
zamoore May 13, 2025
3aa93c4
removing slider component
zamoore May 13, 2025
c18e617
styling the resize handle
zamoore May 13, 2025
eb6388d
resizing with both the keyboard and mouse works
zamoore May 13, 2025
0af3f79
cleaning up PR
zamoore May 13, 2025
937837c
cleaned up PR for review
zamoore May 14, 2025
06e56cd
fixing nested rows
zamoore May 14, 2025
49a729e
removed range slider styles
zamoore May 14, 2025
540f709
pr cleanup
zamoore May 14, 2025
227747f
fixing build issues
zamoore May 14, 2025
0366377
responding to PR feedback
zamoore May 22, 2025
059c1fe
added tests for column resiing
zamoore May 23, 2025
4419898
removed unused import
zamoore May 23, 2025
e05a7de
fixing linting errors
zamoore May 23, 2025
f0bed69
context menu is added
zamoore May 27, 2025
0ed7486
context menu can restore column width
zamoore May 27, 2025
bbde6ce
added context menu and tests for resetting column width
zamoore May 27, 2025
69954db
column resizing is enabled in sortable columns
zamoore May 27, 2025
59edd13
updated styling on th-sort component
zamoore May 28, 2025
9734ff8
styles wip
zamoore May 28, 2025
eab27f6
playing around with minimum widths
zamoore May 28, 2025
ef6ba03
working on styling th elements
zamoore May 28, 2025
fbbb0db
added sorting and nonsorting examples
zamoore May 28, 2025
4ba8e7d
added more showcase examples and fixed the incorrect icon
zamoore May 28, 2025
2ba74a5
added resizable columns in the complex example
zamoore May 28, 2025
03c964b
fixed dropdown context menu toggle button styles
zamoore May 28, 2025
1adc26b
added callback function for column resizing and accompanying test
zamoore May 28, 2025
66297bf
added a changeset
zamoore May 29, 2025
bf75484
added unit test for column class
zamoore May 29, 2025
7bddb7d
pr cleanup
zamoore May 29, 2025
2d64712
responding to PR feedback
zamoore May 29, 2025
1f9cf1d
fixing failing tests
zamoore May 29, 2025
845b424
disallow resizable columns in combo with stickyFirstColumn
zamoore May 29, 2025
4389dca
adding additional tests
zamoore May 29, 2025
526e702
guarding against expandable rows if there are resizable columns
zamoore Jun 1, 2025
2410d6c
respond to changes in the column or data structure
zamoore Jun 2, 2025
886bacd
addressing PR feedback
zamoore Jun 2, 2025
963921c
fix resize handle height
zamoore Jun 3, 2025
6958a18
styling context menu
zamoore Jun 4, 2025
f166ab6
keeps resize handle in view when resizing with the keyboard
zamoore Jun 4, 2025
68f4d65
fixed dropdown toggle styles
zamoore Jun 4, 2025
5d2dd84
working on adding resizable columns when working with sticky columns
zamoore Jun 4, 2025
e360972
responding to PR feedback
zamoore Jun 9, 2025
7e7d73d
responding to PR feedback
zamoore Jun 9, 2025
4bfa65b
fixing after rebase
zamoore Jun 10, 2025
951c7d5
fixing bad rebase
zamoore Jun 10, 2025
f686d88
applying ellipsis style
zamoore Jun 10, 2025
8be2bf8
fixed the focus styles
zamoore Jun 10, 2025
9e59580
move sorting logic to the model
zamoore Jun 11, 2025
80c99c5
fixing modifier
zamoore Jun 11, 2025
b8d921e
added further showcase examples
zamoore Jun 11, 2025
504e4bf
setting resizable at table level works
zamoore Jun 11, 2025
fc07567
removing width req
zamoore Jun 11, 2025
0f68018
improvements to column resizing
zamoore Jun 11, 2025
bdeba95
reset all column widths at once
zamoore Jun 11, 2025
83ca888
reset width wip
zamoore Jun 12, 2025
5dcaffe
restoring borrowed widths to neighbor cell
zamoore Jun 12, 2025
0b63e67
working on resetting size
zamoore Jun 12, 2025
f02ade1
fixed reszing issue
zamoore Jun 12, 2025
46603d2
added comments
zamoore Jun 13, 2025
ddaae2a
fixing failing tests
zamoore Jun 13, 2025
41e6fcf
added additional onResize test
zamoore Jun 13, 2025
58e0588
responding to PR feedback
zamoore Jun 13, 2025
10b6188
responding to PR feedback
zamoore Jun 13, 2025
973c088
fixing linting error
zamoore Jun 13, 2025
f02d03e
fixing a11y test
zamoore Jun 13, 2025
b95fd29
cleaning up PR
zamoore Jun 19, 2025
550e05f
cleaning up PR
zamoore Jun 19, 2025
8a06e46
cleaning up PR
zamoore Jun 19, 2025
4695b8e
responding to PR feedback
zamoore Jun 19, 2025
c97c317
responding to PR feedback
zamoore Jun 20, 2025
523cd8e
removed unneeded import
zamoore Jun 20, 2025
dcc8203
added column resize option to context menu
zamoore Jun 20, 2025
a1e96f7
fixing bug
zamoore Jun 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/chilly-cheetahs-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@hashicorp/design-system-components": minor
---

Added `ember-math-helpers` dependency.

`AdvancedTable` - Added `hasResizableColumns` argument. When `true`, allows the table's columns to be resized with both a click-and-drag and a keyboard interface.
4 changes: 4 additions & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"concurrently": "^9.1.2",
"ember-basic-dropdown": "^8.6.1",
"ember-source": "^6.4.0",
"ember-math-helpers": "^5.0.0",
"ember-template-lint": "^7.0.2",
"ember-template-lint-plugin-prettier": "^5.0.0",
"eslint": "^9.23.0",
Expand Down Expand Up @@ -139,12 +140,15 @@
"./components/hds/accordion/item/index.js": "./dist/_app_/components/hds/accordion/item/index.js",
"./components/hds/advanced-table/expandable-tr-group.js": "./dist/_app_/components/hds/advanced-table/expandable-tr-group.js",
"./components/hds/advanced-table/index.js": "./dist/_app_/components/hds/advanced-table/index.js",
"./components/hds/advanced-table/models/column.js": "./dist/_app_/components/hds/advanced-table/models/column.js",
"./components/hds/advanced-table/models/row.js": "./dist/_app_/components/hds/advanced-table/models/row.js",
"./components/hds/advanced-table/models/table.js": "./dist/_app_/components/hds/advanced-table/models/table.js",
"./components/hds/advanced-table/td.js": "./dist/_app_/components/hds/advanced-table/td.js",
"./components/hds/advanced-table/th-button-expand.js": "./dist/_app_/components/hds/advanced-table/th-button-expand.js",
"./components/hds/advanced-table/th-button-sort.js": "./dist/_app_/components/hds/advanced-table/th-button-sort.js",
"./components/hds/advanced-table/th-button-tooltip.js": "./dist/_app_/components/hds/advanced-table/th-button-tooltip.js",
"./components/hds/advanced-table/th-context-menu.js": "./dist/_app_/components/hds/advanced-table/th-context-menu.js",
"./components/hds/advanced-table/th-resize-handle.js": "./dist/_app_/components/hds/advanced-table/th-resize-handle.js",
"./components/hds/advanced-table/th-selectable.js": "./dist/_app_/components/hds/advanced-table/th-selectable.js",
"./components/hds/advanced-table/th-sort.js": "./dist/_app_/components/hds/advanced-table/th-sort.js",
"./components/hds/advanced-table/th.js": "./dist/_app_/components/hds/advanced-table/th.js",
Expand Down
42 changes: 29 additions & 13 deletions packages/components/src/components/hds/advanced-table/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div
class="hds-advanced-table__container
{{(if this.isStickyHeaderPinned 'hds-advanced-table__container--header-is-pinned')}}"
{{this._didUpdateModel}}
{{did-update this.setupTableModelData @columns @model @sortBy @sortOrder}}
...attributes
>
{{! Caption }}
Expand All @@ -30,8 +30,8 @@
<div class={{this.theadClassNames}} role="rowgroup" {{this._setUpThead}}>
<Hds::AdvancedTable::Tr
@selectionScope="col"
@onClickSortBySelected={{if @selectableColumnKey (fn this.setSortBy @selectableColumnKey)}}
@sortBySelectedOrder={{if (eq this._sortBy @selectableColumnKey) this._sortOrder}}
@onClickSortBySelected={{if @selectableColumnKey (fn this._tableModel.setSortBy @selectableColumnKey)}}
@sortBySelectedOrder={{if (eq this._tableModel.sortBy @selectableColumnKey) this._tableModel.sortOrder}}
@isSelectable={{this.isSelectable}}
@onSelectionChange={{this.onSelectionAllChange}}
@didInsert={{this.didInsertSelectAllCheckbox}}
Expand All @@ -40,29 +40,45 @@
@hasStickyColumn={{@hasStickyFirstColumn}}
@isStickyColumnPinned={{this.isStickyColumnPinned}}
>
{{#each @columns as |column index|}}
{{#each this._tableModel.columns as |column index|}}
{{#if column.isSortable}}
<Hds::AdvancedTable::ThSort
@sortOrder={{if (eq column.key this._sortBy) this._sortOrder}}
@onClickSort={{fn this.setSortBy column.key}}
@column={{column}}
@sortOrder={{if (eq column.key this._tableModel.sortBy) this._tableModel.sortOrder}}
@onClickSort={{if column.key (fn this._tableModel.setSortBy column.key)}}
@align={{column.align}}
@tooltip={{column.tooltip}}
@hasResizableColumns={{@hasResizableColumns}}
@isLastColumn={{eq index (sub this._tableModel.columns.length 1)}}
@isStickyColumn={{if (and (eq index 0) @hasStickyFirstColumn) true}}
@isStickyColumnPinned={{this.isStickyColumnPinned}}
@previousColumn={{get this._tableModel.columns (sub index 1)}}
@nextColumn={{get this._tableModel.columns (add index 1)}}
@tableHeight={{this._tableHeight}}
@onColumnResize={{@onColumnResize}}
{{this._setColumnWidth column}}
>
{{column.label}}
</Hds::AdvancedTable::ThSort>
{{else}}
<Hds::AdvancedTable::Th
@align={{column.align}}
@tooltip={{column.tooltip}}
@isVisuallyHidden={{column.isVisuallyHidden}}
@isExpandable={{column.isExpandable}}
@onClickToggle={{this._tableModel.toggleAll}}
@isExpanded={{this._tableModel.expandState}}
@column={{column}}
@hasExpandAllButton={{this._tableModel.hasRowsWithChildren}}
@hasResizableColumns={{@hasResizableColumns}}
@isExpanded={{this._tableModel.expandState}}
@isExpandable={{column.isExpandable}}
@isLastColumn={{eq index (sub this._tableModel.columns.length 1)}}
@isStickyColumn={{if (and (eq index 0) @hasStickyFirstColumn) true}}
@isStickyColumnPinned={{this.isStickyColumnPinned}}
@isVisuallyHidden={{column.isVisuallyHidden}}
@previousColumn={{get this._tableModel.columns (sub index 1)}}
@nextColumn={{get this._tableModel.columns (add index 1)}}
@tableHeight={{this._tableHeight}}
@tooltip={{column.tooltip}}
@onClickToggle={{this._tableModel.toggleAll}}
@onColumnResize={{@onColumnResize}}
{{this._setColumnWidth column}}
>
{{column.label}}
</Hds::AdvancedTable::Th>
Expand All @@ -78,8 +94,7 @@
we yield the Tr/Td/Th elements _and_ the record itself as `data`
this means the consumer will *have to* use the `data` key to access it in their template
-------------------------------------------------------------------------------------------- }}
{{! @glint-expect-error: [HDS-4380](https://hashicorp.atlassian.net/browse/HDS-4380) }}
{{#each (sort-by this.getSortCriteria this._tableModel.rows) key=this.identityKey as |record index|}}
{{#each this._tableModel.sortedRows key=this.identityKey as |record index|}}
{{#if this._tableModel.hasRowsWithChildren}}
<Hds::AdvancedTable::ExpandableTrGroup
@record={{record}}
Expand Down Expand Up @@ -145,6 +160,7 @@
{{/each}}
</div>
</div>

{{#if this.showScrollIndicatorLeft}}
<div
class="hds-advanced-table__scroll-indicator hds-advanced-table__scroll-indicator-left"
Expand Down
Loading