Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
70d5559
add reorder components
zamoore Jul 7, 2025
2ad6f29
picking reorder code
zamoore Jul 7, 2025
788eef0
pulling in styling
zamoore Jul 7, 2025
733baf9
set up initial showcase example
zamoore Jul 8, 2025
4ed5a9f
working on styling
zamoore Jul 8, 2025
adcc00d
adding tests
zamoore Jul 9, 2025
cdf739b
working on adding tests for drag/drop behavior
zamoore Jul 9, 2025
00ace6f
cleaning up visuals
zamoore Jul 11, 2025
433e9f4
styling the reorder handle
zamoore Jul 11, 2025
77a4e10
styling reorderable columns
zamoore Jul 15, 2025
f9c04c7
adding dropdown context options for reordering
zamoore Jul 15, 2025
a629f0c
working on context menu options for reordering
zamoore Jul 15, 2025
66c79d2
can send column to first/last
zamoore Jul 16, 2025
8238e27
applying new reorder handle styles
zamoore Jul 16, 2025
6787efa
can step column with keyboard
zamoore Jul 16, 2025
fe43c94
keyboard movement works
zamoore Jul 16, 2025
c5698dd
added tests for context menu opptions
zamoore Jul 16, 2025
00a31db
adding tests for context menu action execution
zamoore Jul 16, 2025
67da9d3
added tests for reordering columns with focus/arrowkeys
zamoore Jul 16, 2025
b168775
styling srag target
zamoore Jul 16, 2025
8facd98
fixed reorder handle styles
zamoore Jul 17, 2025
9cbefdd
added styles for focus-within
zamoore Jul 17, 2025
c5f4f78
working on programatic focus for reorder handle
zamoore Jul 17, 2025
310a7d8
added reorder capabilities to sortable columns
zamoore Jul 21, 2025
19108ba
reordering resized columns preserves the column size
zamoore Jul 21, 2025
6154a12
resizing reordered columns works
zamoore Jul 21, 2025
f92dbf0
making resizing and reordering work together
zamoore Jul 21, 2025
c89cbdb
working on width ledger
zamoore Jul 22, 2025
b2f2054
resizing works again but with a ledger system now
zamoore Jul 22, 2025
688ca3e
reordering and resizing work together
zamoore Jul 22, 2025
7488912
fix: reorder handle focus bug
Aug 1, 2025
b3c9b9b
merging main
zamoore Aug 8, 2025
0b02296
fixing ts error
zamoore Aug 8, 2025
5b80f06
fixed scroll stutter
zamoore Aug 8, 2025
0c119a3
updated nontranslated string
zamoore Aug 11, 2025
1b78bac
correctly calculating column width at drag start in order to construc…
zamoore Aug 11, 2025
61cbf7a
fixing drop target styles
zamoore Aug 11, 2025
a843397
fixed an issue with setting in nested rows
zamoore Aug 11, 2025
a40220f
adding a default column key (generated)
zamoore Aug 11, 2025
3aa9d53
added an assertion for trying to use reorderable columns with nested …
zamoore Aug 12, 2025
8ac2f35
got reorderable columns working with sticky first column
zamoore Aug 12, 2025
1ba94a9
Merge branch 'main' into zamoore/AdvancedTable/column-reordering-2
zamoore Aug 12, 2025
59758cd
made the demo reorderable
zamoore Aug 12, 2025
ad62203
adding showcase examples
zamoore Aug 12, 2025
d5959bc
adding showcase examples
zamoore Aug 13, 2025
89a0568
fixed firefox reorder bug
zamoore Aug 13, 2025
06e1fc1
wip target styles
zamoore Aug 14, 2025
1bc2036
merge main
zamoore Aug 14, 2025
8f66211
cleaning up PR and adding more tests
zamoore Aug 14, 2025
4804a4d
moving columns with sticky columns works
zamoore Aug 15, 2025
29113bf
prevent users from using keyboard nav to move column to sticky column…
zamoore Aug 15, 2025
8d15dc5
adding tests around reordering and sticky columns
zamoore Aug 15, 2025
65ea884
reverting a change to the gridTemplateColumns getter
zamoore Aug 15, 2025
1d78f3c
not showing context menu if there are no reorder options
zamoore Aug 15, 2025
8beaea8
cleaned up column order getter
zamoore Aug 15, 2025
0b20575
fixed a bug where resizing reordered columns was resizing the wrong c…
zamoore Aug 15, 2025
367c2a2
merge main
zamoore Aug 25, 2025
93d3f03
added some throttling to resizing to prevent lag
zamoore Aug 25, 2025
0528abb
merged main
zamoore Aug 25, 2025
44e972b
getting width repayment working with column reordering
zamoore Aug 25, 2025
aaca8f0
fixing width reset
zamoore Aug 26, 2025
2566e2a
remove glint disable comment
zamoore Aug 26, 2025
6ae6722
fixing linting errors
zamoore Aug 26, 2025
2128db7
change the model type
zamoore Aug 26, 2025
63c7331
fixing linting errors
zamoore Aug 26, 2025
4e95dfb
fixing linting errors
zamoore Aug 26, 2025
ba38777
removing unnecessary type assertion
zamoore Aug 26, 2025
555c480
Merge branch 'main' into zamoore/AdvancedTable/column-reordering-2
zamoore Aug 26, 2025
a1e060f
fixing a11y violation
zamoore Aug 26, 2025
77f05dc
fixing tests
zamoore Aug 26, 2025
6701fca
green tests
zamoore Aug 27, 2025
f6e38f7
added test waiter
zamoore Aug 27, 2025
2d273a2
fixing broken unit tests
zamoore Aug 27, 2025
18588f2
Merge branch 'main' into zamoore/AdvancedTable/column-reordering-2
zamoore Aug 28, 2025
6afab77
increased the target for the reorder handle
zamoore Aug 28, 2025
70a7cc8
changed order of th components
zamoore Aug 28, 2025
26dc0f0
fixing linting error
zamoore Aug 29, 2025
b0a3c7d
responding to pr feedback
zamoore Aug 29, 2025
09409fc
responding to pr feedback
zamoore Aug 29, 2025
849ad53
addressing PR feedback
zamoore Sep 2, 2025
13889dd
adding new test for context menu options for sticky col
zamoore Sep 2, 2025
0022714
added an example with reorderable columns and selectable rows
zamoore Sep 2, 2025
3bb1222
addressing PR feedback
zamoore Sep 2, 2025
b6bf61a
fixed dynamic segment in translation
zamoore Sep 2, 2025
539f54a
correctly updates the column order when the value changes both intern…
zamoore Sep 8, 2025
eee4fad
Merge branch 'main' into zamoore/AdvancedTable/column-reordering-2
zamoore Sep 8, 2025
d40df90
not showing pin/unpin option if columns are reorderable
zamoore Sep 8, 2025
793ec95
no longer showing 'move to first' option in context menu if there is …
zamoore Sep 8, 2025
1a6495d
ammending tests
zamoore Sep 8, 2025
d644586
fixed the focus ring style on the reorder handle
zamoore Sep 8, 2025
be759d5
made sure the drop target had the correct styles when dropping on tab…
zamoore Sep 9, 2025
9d4c011
removed support for hasStickyFirstColumn together with hasReorderable…
zamoore Sep 10, 2025
4e5cc9d
fixed assertion test
zamoore Sep 10, 2025
a3b35ee
removed column reordering from the generic advanced table example
zamoore Sep 10, 2025
f044514
set up overflowing table for sortable demo
zamoore Sep 10, 2025
b6ec224
scrollIntoView works when reordering
zamoore Sep 10, 2025
809e9c3
registering context menu toggle with the column class
zamoore Sep 10, 2025
e3715a6
refocusing the dropdown toggle when using the context menu to reorder
zamoore Sep 11, 2025
76bba42
removed the console log
zamoore Sep 11, 2025
7d2967a
responding to PR feedback
zamoore Sep 11, 2025
5adee74
fixed an issue with reordering on sortable columns
zamoore Sep 11, 2025
6b2ecde
Merge branch 'main' into zamoore/AdvancedTable/column-reordering-2
zamoore Sep 11, 2025
f7c9be1
added a changeset
zamoore Sep 11, 2025
04c1ca1
updated changeset
zamoore Sep 11, 2025
bf3817b
Apply suggestions from code review
zamoore Sep 12, 2025
51315d4
Merge branch 'main' into zamoore/AdvancedTable/column-reordering-2
zamoore Sep 14, 2025
3fe499a
change where the top scroll indicator renders
zamoore Sep 15, 2025
8e5cf3f
fixed a linting error
zamoore Sep 15, 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
11 changes: 11 additions & 0 deletions .changeset/wet-files-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@hashicorp/design-system-components": minor
---

<!-- START components/table/advanced-table -->
`AdvancedTable` - Added support for column reordering.
- Added `@hasReorderableColumns` argument. When set to `true`, enables column reordering.
- Added optional `@columnOrder` argument for setting the initial order of columns by their keys.
- Added optional `@onColumnReorder` argument which accepts a callback function that is called when reordering is completed.
- Added optional `@reorderedMessageText` which overrides the default message text that is rendered in the table caption when a column is reordered.
<!-- END -->
3 changes: 3 additions & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,14 @@
"./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-reorder-drop-target.js": "./dist/_app_/components/hds/advanced-table/th-reorder-drop-target.js",
"./components/hds/advanced-table/th-reorder-handle.js": "./dist/_app_/components/hds/advanced-table/th-reorder-handle.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",
"./components/hds/advanced-table/tr.js": "./dist/_app_/components/hds/advanced-table/tr.js",
"./components/hds/advanced-table/utils.js": "./dist/_app_/components/hds/advanced-table/utils.js",
"./components/hds/alert/description.js": "./dist/_app_/components/hds/alert/description.js",
"./components/hds/alert.js": "./dist/_app_/components/hds/alert.js",
"./components/hds/alert/title.js": "./dist/_app_/components/hds/alert/title.js",
Expand Down
35 changes: 26 additions & 9 deletions packages/components/src/components/hds/advanced-table/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}

<div
class="hds-advanced-table__container
{{(if this.isStickyHeaderPinned 'hds-advanced-table__container--header-is-pinned')}}"
{{did-update this.setupTableModelData @columns @model @sortBy @sortOrder}}
{{did-update this.updateTableModelColumnOrder @columnOrder}}
...attributes
>
{{! Caption }}
<div id={{this._captionId}} class="sr-only hds-advanced-table__caption" aria-live="polite">
{{@caption}}
{{this.sortedMessageText}}
{{this.reorderedMessageText}}
</div>

{{! Grid }}
Expand All @@ -28,7 +31,12 @@
{{this._setUpScrollWrapper}}
>
{{! Header }}
<div class={{this.theadClassNames}} role="rowgroup" {{this._setUpThead}}>
<div
class={{this.theadClassNames}}
role="rowgroup"
{{this._setUpThead}}
{{on "dragleave" (fn (mut this._tableModel.reorderHoveredColumn) null)}}
>
<Hds::AdvancedTable::Tr
@selectionScope="col"
@onClickSortBySelected={{if @selectableColumnKey (fn this._tableModel.setSortBy @selectableColumnKey)}}
Expand All @@ -41,20 +49,25 @@
@hasStickyColumn={{this.hasStickyFirstColumn}}
@isStickyColumnPinned={{this.isStickyColumnPinned}}
>
{{#each this._tableModel.columns as |column|}}
{{#each this._tableModel.orderedColumns as |column|}}
{{#if column.isSortable}}
<Hds::AdvancedTable::ThSort
@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}}
@hasReorderableColumns={{@hasReorderableColumns}}
@hasResizableColumns={{@hasResizableColumns}}
@hasSelectableRows={{this.isSelectable}}
@isStickyColumn={{this._isStickyColumn column}}
@isStickyColumnPinned={{this.isStickyColumnPinned}}
@tableHeight={{this._tableHeight}}
@onColumnResize={{@onColumnResize}}
@onPinFirstColumn={{this._onPinFirstColumn}}
@onReorderDragEnd={{fn (mut this._tableModel.reorderDraggedColumn) null}}
@onReorderDragStart={{fn (mut this._tableModel.reorderDraggedColumn)}}
@onReorderDrop={{this._tableModel.moveColumnToDropTarget}}
{{this._registerThElement column}}
>
{{column.label}}
Expand All @@ -64,7 +77,9 @@
@align={{column.align}}
@column={{column}}
@hasExpandAllButton={{this._tableModel.hasRowsWithChildren}}
@hasReorderableColumns={{@hasReorderableColumns}}
@hasResizableColumns={{@hasResizableColumns}}
@hasSelectableRows={{this.isSelectable}}
@isExpanded={{this._tableModel.expandState}}
@isExpandable={{column.isExpandable}}
@isStickyColumn={{this._isStickyColumn column}}
Expand All @@ -75,13 +90,20 @@
@onClickToggle={{this._tableModel.toggleAll}}
@onColumnResize={{@onColumnResize}}
@onPinFirstColumn={{this._onPinFirstColumn}}
@onReorderDragEnd={{fn (mut this._tableModel.reorderDraggedColumn) null}}
@onReorderDragStart={{fn (mut this._tableModel.reorderDraggedColumn)}}
@onReorderDrop={{this._tableModel.moveColumnToDropTarget}}
{{this._registerThElement column}}
>
{{column.label}}
</Hds::AdvancedTable::Th>
{{/if}}
{{/each}}
</Hds::AdvancedTable::Tr>

{{#if this.showScrollIndicatorTop}}
<div class="hds-advanced-table__scroll-indicator hds-advanced-table__scroll-indicator-top" />
{{/if}}
</div>

{{! Body }}
Expand All @@ -107,6 +129,7 @@
isParentRow=T.isExpandable
depth=T.depth
displayRow=T.shouldDisplayChildRows
data=T.data
)
Th=(component
"hds/advanced-table/th"
Expand Down Expand Up @@ -140,6 +163,7 @@
selectionAriaLabelSuffix=@selectionAriaLabelSuffix
hasStickyColumn=this.hasStickyFirstColumn
isStickyColumnPinned=this.isStickyColumnPinned
data=record
)
Th=(component
"hds/advanced-table/th"
Expand Down Expand Up @@ -172,13 +196,6 @@
/>
{{/if}}

{{#if this.showScrollIndicatorTop}}
<div
class="hds-advanced-table__scroll-indicator hds-advanced-table__scroll-indicator-top"
{{style top=this.scrollIndicatorDimensions.top width=this.scrollIndicatorDimensions.width}}
/>
{{/if}}

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