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

Open
wants to merge 81 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
527cd1b
added column model
zamoore May 1, 2025
0aee1c5
column resizing works
zamoore May 1, 2025
108ff50
resize handle extends to full height of table
zamoore May 2, 2025
bd89a5d
adding a11y improvements
zamoore May 2, 2025
df8eed7
a11y enhancements
zamoore May 5, 2025
c09a540
comleted inital styling on range input
zamoore May 5, 2025
5a1dc61
resizing columns works with both the slider and the column border
zamoore May 7, 2025
edff675
requiring widths for resize
zamoore May 7, 2025
207949b
reset width works
zamoore May 7, 2025
74083c3
column resize in progress
zamoore May 9, 2025
d82d0b7
calculating percentage based on table width
zamoore May 9, 2025
c6fcc3d
mixed unit math works
zamoore May 9, 2025
8e7f1ef
cleaned up the column model
zamoore May 9, 2025
9cdf768
correctly works with pixel vals
zamoore May 12, 2025
9cd40d7
cleaning up
zamoore May 13, 2025
8dac899
simplified the th api
zamoore May 13, 2025
9534a83
removing slider component
zamoore May 13, 2025
5db49dd
styling the resize handle
zamoore May 13, 2025
42adf06
resizing with both the keyboard and mouse works
zamoore May 13, 2025
5b7d5b8
cleaning up PR
zamoore May 13, 2025
40d08b0
cleaned up PR for review
zamoore May 14, 2025
185cfa6
fixing nested rows
zamoore May 14, 2025
0f9466c
removed range slider styles
zamoore May 14, 2025
8813761
pr cleanup
zamoore May 14, 2025
726ed60
fixing build issues
zamoore May 14, 2025
2428dee
responding to PR feedback
zamoore May 22, 2025
27b5a9a
added tests for column resiing
zamoore May 23, 2025
959ceba
removed unused import
zamoore May 23, 2025
4b88318
fixing linting errors
zamoore May 23, 2025
4125eda
context menu is added
zamoore May 27, 2025
c8f149c
context menu can restore column width
zamoore May 27, 2025
b433d79
added context menu and tests for resetting column width
zamoore May 27, 2025
998d240
column resizing is enabled in sortable columns
zamoore May 27, 2025
c6cad65
updated styling on th-sort component
zamoore May 28, 2025
e55c01d
styles wip
zamoore May 28, 2025
28e63b5
playing around with minimum widths
zamoore May 28, 2025
a5d863d
working on styling th elements
zamoore May 28, 2025
5a43f21
added sorting and nonsorting examples
zamoore May 28, 2025
4576378
added more showcase examples and fixed the incorrect icon
zamoore May 28, 2025
9edde02
added resizable columns in the complex example
zamoore May 28, 2025
2d36743
fixed dropdown context menu toggle button styles
zamoore May 28, 2025
fc87822
added callback function for column resizing and accompanying test
zamoore May 28, 2025
a9a9795
added a changeset
zamoore May 29, 2025
709128a
added unit test for column class
zamoore May 29, 2025
a7c6769
pr cleanup
zamoore May 29, 2025
7b21f3c
responding to PR feedback
zamoore May 29, 2025
6914f81
fixing failing tests
zamoore May 29, 2025
dafb096
disallow resizable columns in combo with stickyFirstColumn
zamoore May 29, 2025
6a012f0
adding additional tests
zamoore May 29, 2025
253d333
guarding against expandable rows if there are resizable columns
zamoore Jun 1, 2025
40baad1
respond to changes in the column or data structure
zamoore Jun 2, 2025
54a8c2b
addressing PR feedback
zamoore Jun 2, 2025
9c40f72
fix resize handle height
zamoore Jun 3, 2025
781eaf7
styling context menu
zamoore Jun 4, 2025
388f4e7
keeps resize handle in view when resizing with the keyboard
zamoore Jun 4, 2025
34ab6e0
fixed dropdown toggle styles
zamoore Jun 4, 2025
f0b1e1f
working on adding resizable columns when working with sticky columns
zamoore Jun 4, 2025
e98460f
responding to PR feedback
zamoore Jun 9, 2025
83b3617
responding to PR feedback
zamoore Jun 9, 2025
57117b9
fixing after rebase
zamoore Jun 10, 2025
f6b144d
fixing bad rebase
zamoore Jun 10, 2025
32740a9
applying ellipsis style
zamoore Jun 10, 2025
df98ae1
fixed the focus styles
zamoore Jun 10, 2025
19162f7
move sorting logic to the model
zamoore Jun 11, 2025
6f7bed5
fixing modifier
zamoore Jun 11, 2025
6da38eb
added further showcase examples
zamoore Jun 11, 2025
cb2979b
setting resizable at table level works
zamoore Jun 11, 2025
8fb5f1f
removing width req
zamoore Jun 11, 2025
1e2f87c
improvements to column resizing
zamoore Jun 11, 2025
7f56225
reset all column widths at once
zamoore Jun 11, 2025
8d57861
reset width wip
zamoore Jun 12, 2025
24abe4e
restoring borrowed widths to neighbor cell
zamoore Jun 12, 2025
0f5dead
working on resetting size
zamoore Jun 12, 2025
2c1c8af
fixed reszing issue
zamoore Jun 12, 2025
2f58eff
added comments
zamoore Jun 13, 2025
f1335e0
fixing failing tests
zamoore Jun 13, 2025
93a06a3
added additional onResize test
zamoore Jun 13, 2025
e3c099f
responding to PR feedback
zamoore Jun 13, 2025
be37290
responding to PR feedback
zamoore Jun 13, 2025
cc5569d
fixing linting error
zamoore Jun 13, 2025
d243eb8
fixing a11y test
zamoore Jun 13, 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
---

`AdvancedTable` - Added `isResizable` option to column object. When `true`, allows the column to be resized with both a click-and-drag and a keyboard interface.

Added `ember-math-helpers` dependency.
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
41 changes: 29 additions & 12 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,7 +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
-------------------------------------------------------------------------------------------- }}
{{#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 @@ -144,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