Skip to content

Commit 1f06d45

Browse files
zamoorejorytindallshleewhite
authored
AdvancedTable - Column reordering - Docs (#3194)
Co-authored-by: Jory Tindall <[email protected]> Co-authored-by: shleewhite <[email protected]>
1 parent 881ce88 commit 1f06d45

19 files changed

+121
-12
lines changed

website/cspell-config/project-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Wireframes
6767
wireframing
6868
workramp
6969
nullvoxpopuli
70+
reorderable
7071

7172
# Component-specific
7273
dont

website/docs/components/table/advanced-table/partials/accessibility/accessibility.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,40 @@ Focus will be moved to the resize border. Use the right and left arrow keys to i
145145

146146
![Keyboard focus on the resize border for the column.](/assets/components/table/advanced-table/advanced-table-keyboard-action-mode-resize-border.png)
147147

148+
### Reordering columns
149+
150+
<Doc::Badge @type="neutral">Tab</Doc::Badge>
151+
152+
While in Action Mode, Tab to the context menu.
153+
154+
![Keyboard focus on the context menu within the column header.](/assets/components/table/advanced-table/advanced-table-keyboard-action-reorder.png)
155+
156+
<Doc::Badge @type="neutral">Enter</Doc::Badge>
157+
158+
Press Enter to open the context menu.
159+
160+
![The open context menu with the move column option.](/assets/components/table/advanced-table/advanced-table-keyboard-action-reorder-context-menu.png)
161+
162+
<Doc::Badge @type="neutral">Tab</Doc::Badge>
163+
164+
With the context menu open, press Tab to select the `Move column` option.
165+
166+
![Keyboard focus on the move column option in the context menu.](/assets/components/table/advanced-table/advanced-table-keyboard-action-reorder-move-column.png)
167+
168+
<Doc::BadgeGroup>
169+
<Doc::Badge @type="neutral">
170+
<Hds::Icon @name="arrow-left" @title="Left arrow" />
171+
</Doc::Badge>
172+
<Doc::Badge @type="neutral">
173+
<Hds::Icon @name="arrow-right" @title="Right` arrow" />
174+
</Doc::Badge>
175+
</Doc::BadgeGroup>
176+
177+
Focus will be moved to the reorder handle. Use the right and left arrow keys to move the column to the next or previous position.
178+
179+
![Keyboard focus on the reorder handle for the column.](/assets/components/table/advanced-table/advanced-table-keyboard-action-reorder-drag-handle.png)
180+
181+
148182
### Row selection
149183

150184
You should clearly communicate to the user how many rows are selected and how many rows there are total outside of the Advanced Table. For additional considerations, read the [Multi-select usability and accessibility considerations](/components/table/advanced-table?tab=code#usability-and-accessibility-considerations).

website/docs/components/table/advanced-table/partials/code/component-api.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,26 @@ The Advanced Table component itself is where most of the options will be applied
7878
</C.Property>
7979
</Doc::ComponentApi>
8080
</C.Property>
81+
<C.Property @name="columnOrder" @type="array">
82+
Array of column keys that determines the initial order of table columns. Keys in this array must match `key` values present in objects in the `columns` argument.
83+
</C.Property>
84+
<C.Property @name="hasReorderableColumns" @type="boolean" @default="false">
85+
If set to `true`, allows users to reorder columns either by clicking and dragging on the column reorder handle with a mouse, or by moving focus to the handle with a keyboard and using the right and left arrow keys.
86+
</C.Property>
87+
<C.Property @name="reorderedMessageText" @type="string" @default="Moved (label) column to (position)">
88+
Customizable text added to `caption` element when a column reorder is performed.
89+
</C.Property>
8190
<C.Property @name="hasResizableColumns" @type="boolean" @default="false">
8291
If set to `true`, allows users to resize columns either by clicking and dragging on the column border with a mouse, or by moving focus to the resize border with a keyboard and using the right and left arrow keys.
8392
</C.Property>
93+
<C.Property @name="onColumnReorder" @type="function">
94+
Use in conjunction with `hasReorderableColumns` to pass a callback function to know the updated column order after a reorder event.
95+
<br /><br />
96+
When called, this function receives one positional argument:
97+
<ul>
98+
<li>an array of reordered column keys (e.g., `['name', 'age', 'height']`).</li>
99+
</ul>
100+
</C.Property>
84101
<C.Property @name="onColumnResize" @type="function">
85102
Use in conjunction with `hasResizableColumns` to pass a callback function to know the updated width of a resized column.
86103
<br /><br />

website/docs/components/table/advanced-table/partials/code/how-to-use.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,40 @@ Similar to the basic Advanced Table, you can insert your own content into the `:
148148
</Hds::AdvancedTable>
149149
```
150150

151-
### Resizable Columns
151+
### Reordering columns
152+
153+
!!! Info
154+
155+
Reorderable columns are not supported in instances of the Advanced Table that have nested rows or sticky columns.
156+
!!!
157+
158+
Set the `@hasReorderableColumns` argument to `true` in order to make columns reorderable either by clicking and dragging on the column reorder handle, or by moving focus to the handle and using the right and left arrow keys.
159+
160+
Columns will render in the order they appear in the `@columns` array. However, this order can be overridden by providing an array of column keys to the `@columnOrder` argument.
161+
162+
Optionally, the `@onColumnReorder` attribute accepts a callback function that receives the updated column key order.
163+
164+
```handlebars
165+
<Hds::AdvancedTable
166+
@model={{this.model.myDemoData}}
167+
@hasReorderableColumns={{true}}
168+
@columns={{array
169+
(hash key="artist" label="Artist" isSortable=true)
170+
(hash key="album" label="Album" isSortable=true)
171+
(hash key="year" label="Release Year")
172+
}}
173+
>
174+
<:body as |B|>
175+
<B.Tr>
176+
<B.Td>{{B.data.artist}}</B.Td>
177+
<B.Td>{{B.data.album}}</B.Td>
178+
<B.Td>{{B.data.year}}</B.Td>
179+
</B.Tr>
180+
</:body>
181+
</Hds::AdvancedTable>
182+
```
183+
184+
### Resizing Columns
152185

153186
!!! Info
154187

@@ -271,13 +304,6 @@ How resizing for the cell content works is determined by the implementation. For
271304

272305
### Sortable Advanced Table
273306

274-
!!! Insight
275-
276-
**Code tip**
277-
278-
This component takes advantage of the `sort-by` helper provided by [@nullvoxpopuli/ember-composable-helpers](https://github.com/NullVoxPopuli/ember-composable-helpers)
279-
!!!
280-
281307
!!! Callout
282308

283309
At this time, the Advanced Table does not support sortable nested rows. If this is a use case you require, please [contact the Design Systems Team](/about/support).

website/docs/components/table/advanced-table/partials/guidelines/guidelines.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,35 @@ Don’t center header labels or cell content within a table.
124124

125125
!!!
126126

127-
### Resizable columns
127+
### Reordering columns
128+
129+
If `hasReorderableColumns` is enabled on the Ember component, users can reorder columns either by clicking and dragging on the column reorder handle with a mouse, or by moving focus to the handle with a keyboard and using the right and left arrow keys.
130+
131+
!!! Info
132+
133+
While these properties aren't available in the Figma component, [examples](https://www.figma.com/design/iweq3r2Pi8xiJfD9e6lOhF/HDS-Components-v2.0?m=auto&node-id=81060-291665&t=KXQulxNCTwGhmCX5-1) are available to copy and paste into design files.
134+
!!!
135+
136+
![](/assets/components/table/advanced-table/advanced-table-focus-drag-target.png)
137+
138+
![](/assets/components/table/advanced-table/advanced-table-drag-column.png)
139+
140+
Actions related to moving columns are displayed in a context menu in the table header. These are not customizable and include:
141+
142+
- Move column: moves focus to the reordering handle
143+
- Move column to start/end: moves the column to the first or last position in the table unless the column is already in this position.
144+
145+
![The open context menu in the Advanced Table displaying "Move column", "Move column to start", and "Move column to end" actions.](/assets/components/table/advanced-table/advanced-table-reorder-context-menu.png)
146+
147+
### Resizing columns
128148

129149
Columns can be resized by dragging the "resize border" with a mouse or by moving focus to it and using the left and right arrow keys.
130150

151+
!!! Info
152+
153+
While these properties aren't available in the Figma component, [examples](https://www.figma.com/design/iweq3r2Pi8xiJfD9e6lOhF/HDS-Components-v2.0?m=auto&node-id=81060-291665&t=UHpPyO7erZKLy4SD-1) are available to copy and paste into design files and the [Resize Border](https://www.figma.com/design/iweq3r2Pi8xiJfD9e6lOhF/HDS-Components-v2.0?m=auto&node-id=80647-127234&t=UHpPyO7erZKLy4SD-1) is available to use as a starting point for expressing this interaction.
154+
!!!
155+
131156
The Figma component does not support this resizing feature. Instead, we publish a [Resize Border](https://www.figma.com/design/iweq3r2Pi8xiJfD9e6lOhF/HDS-Components-v2.0?m=auto&node-id=80647-127234&t=UHpPyO7erZKLy4SD-1) component and [Templates](https://www.figma.com/design/iweq3r2Pi8xiJfD9e6lOhF/HDS-Components-v2.0?m=auto&node-id=72039-5091&t=UHpPyO7erZKLy4SD-1) to use as a starting point for expressing this interaction. We also provide [examples](https://www.figma.com/design/iweq3r2Pi8xiJfD9e6lOhF/HDS-Components-v2.0?m=auto&node-id=81060-291665&t=UHpPyO7erZKLy4SD-1) that you can copy and paste into your design files.
132157

133158
![The interactive resize border in its active state being dragged with a mouse](/assets/components/table/advanced-table/advanced-table-resize-interaction.png)
@@ -236,7 +261,7 @@ Striping enhances readability by alternating row colors, making it easier to sca
236261
The row placement property is only relevant within Figma and doesn’t exist as a property within the code.
237262
!!!
238263

239-
The `rowPlacement` property determines the border radius of a cell. It is only available on cells where the `colPlacement` property is set to `start` or `end`.
264+
The `rowPlacement` property determines the border radius of a cell. It is only available on cells where the `colPlacement` property is set to `start` or `end`.
240265

241266
![The cell with column placement end and row placement end has a border radius set on the bottom right corner.](/assets/components/table/advanced-table/table-row-placement.png)
242267

@@ -280,7 +305,7 @@ If `hasStickyFirstColumn` is set to true or false in the Ember component, a cont
280305
Multi-select is not supported for nested rows at this time.
281306
!!!
282307

283-
Multi-select allows users to select multiple rows to perform bulk actions, such as deleting or exporting data. Selection states are maintained across pagination and filtering.
308+
Multi-select allows users to select multiple rows to perform bulk actions, such as deleting or exporting data. Selection states are maintained across pagination and filtering.
284309

285310
A multi-select pattern consists of:
286311

website/docs/components/table/advanced-table/partials/specifications/anatomy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
| Element | Usage |
2121
| -------------------------------- | --------------------------------------------------------------------------- |
22-
| Context menu and resize controls | Optional, conditionally renders when `@hasResizableColumns` is set to true. |
22+
| Context menu and actions | Optional, conditionally renders when a column has context menu actions available for interactions such as resizing, reordering, or pinning. |
2323

2424
### Advanced Table cells
2525

website/docs/components/table/advanced-table/partials/specifications/states.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ Cells have a default and focused state. The focused state provides visual feedba
1111
To indicate interactivity, the border on a resizable column has visual interactive states.
1212

1313
![Resize border states](/assets/components/table/advanced-table/advanced-table-resize-border-states.png)
14+
15+
### Drag handle
16+
17+
The drag handle is displayed either when hovering on a table header with a mouse, or when focus is moved to it from the context menu.
18+
19+
![Drag handle states](/assets/components/table/advanced-table/advanced-table-drag-handle-button-states.png)
61.1 KB
Loading
16 KB
Loading
57 KB
Loading

0 commit comments

Comments
 (0)