-
Notifications
You must be signed in to change notification settings - Fork 861
[EuiDataGrid] Implement draggable column headers #8015
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
mgadewoll
merged 65 commits into
elastic:main
from
mgadewoll:datagrid/7136-draggable-column-headers
Oct 10, 2024
Merged
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
7a43829
feat: enable draggable datagrid column headers
mgadewoll 08f3583
test: add tests and update snapshots
mgadewoll 64d52ee
fix: update datagrid story column order aligning with visibleColumns
mgadewoll ae292c9
refactor: ensure focus management for draggable cells
mgadewoll 9a5576b
test: add test for draggable cell focus behavior
mgadewoll 94c23cf
fix: ensure expected border and space styles
mgadewoll 5f61f55
refactor: ensure accessible screen reader output
mgadewoll d8a8224
docs: add EUI docs example
mgadewoll f7d2adb
chore: add changelog
mgadewoll fab5380
docs: align EUI docs example with other examples
mgadewoll 41b8d59
refactor: use portal for dragged items
mgadewoll b80e773
refactor: cleanup
mgadewoll da831e3
refactor: use portal inside datagrid to ensure scoped styles still apply
mgadewoll 0632be7
test(VRT): update reference images
mgadewoll 2edb2a6
fix: ensure there is only a single draggable element
mgadewoll 8bcdf6a
test: update cypress test to work with portalled draggable cell
mgadewoll a16b314
refactor: add dragging hint only on non-entered header cell
mgadewoll de342bc
refactor: remove tabindex from drag wrapper for fully custom draggabl…
mgadewoll 85226e7
refactor: add useCallbacks
mgadewoll ce61447
styles: cleanup
mgadewoll d76447b
docs: update column dragging example
mgadewoll c983138
refactor: dry-out actions styles
mgadewoll ddc8690
test: update snapshots
mgadewoll 513998b
refactor: move column drag prop under columnVisibility
mgadewoll 75c3fd2
docs(storybook): add column drag story
mgadewoll 6bf338f
test(VRT): add reference images
mgadewoll 62938ed
refactor: change portal position and fix visual issues
mgadewoll b4a751a
test(VRT): update reference images
mgadewoll 60a0824
chore: update changelog
mgadewoll d64ebb8
refactor: use EuiDraggable usePortal instead of custom EuiPortal for …
mgadewoll 87c0a74
test(VRT): update VRT images
mgadewoll cab7faf
[PR feedback] Clean up header row droppable styles
cee-chen 969851d
Fix `gap` CSS being lost on header actions open
cee-chen d100bd8
[cleanup] Move actions popover logic out of the wrapper and into `dat…
cee-chen 96f325e
Remove onBlur event in favor of blocking any drags/closing any open p…
cee-chen 573ed22
[cleanup] Remove unnecessary `wrapperRef` waterfalling
cee-chen c63040c
Syntax nit cleanups
cee-chen 114a5f4
[UX polish] Improve mouse drag UX for both reordering and resizing co…
cee-chen 4d7945e
[UX polish] Add more visual affordance to keyboard drag start
cee-chen 42c46d2
Fix broken scrolling to draggable header cells
cee-chen 478adbd
Fix columns sometimes not being full height while dragging
cee-chen b8e5393
[Storybook] Add interactive element to draggable storybook
cee-chen ae21c3f
[refactor] Move all drag-related components/logic to its own file/com…
cee-chen 3258fd2
[cleanup] Remove need to pass `isDragging` or `closeActionsPopover` t…
cee-chen abd1a04
[UX polish] Add a stopgap data attr that prevents the hover animation…
cee-chen 7757eac
[opinionated] Revert EuiDraggable changes
cee-chen b50182d
[refactor pt 1] Move column sorting logic to its own file
cee-chen a2b3352
[refactor pt 2] Move actions popover keyboard logic to `column_action…
cee-chen a333a36
[refactor pt 3] Move all column action popover logic to `column_actions`
cee-chen f9f7593
[naming pt 1] rename various column action booleans to be more consis…
cee-chen 74d4115
[naming pt 2] rename `column_resizer` file to match other utils / non…
cee-chen 92a9fdf
chore: revert to customDragHandle='custom'
mgadewoll 2194419
refactor: rewrite adding aria-describedby ids by using destructuring
mgadewoll b256ff6
fix: ensure cell focus context is updated on aborted drag
mgadewoll 567684c
Move draggable column E2E tests to their own file
cee-chen 1255321
Fix another focus bug where grid body could become untabbable
cee-chen 26c72d5
Add a fix for focus traps being enterable while dragging
cee-chen 955cef7
feat: add column width cache
mgadewoll a73ced5
Fix failing style test
cee-chen ec1835c
Fix a `:last-child` CSS selector that no longer applies after drag/dr…
cee-chen 8361d71
Update downstream resizer snapshots
cee-chen 7111417
[refactor] DRY out `isLastColumn` logic
cee-chen 429b9e7
Merge branch 'main' into datagrid/7136-draggable-column-headers
cee-chen fb3ff84
[PR feedback] Column widths
cee-chen 219040a
test(VRT): update reference images
mgadewoll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file modified
BIN
-1 Byte
(100%)
...eui/.loki/reference/chrome_desktop_Tabular_Content_EuiDataGrid_Cell_Actions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2 Bytes
(100%)
...reference/chrome_desktop_Tabular_Content_EuiDataGrid_Cell_Expansion_Popover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1 Byte
(100%)
.../reference/chrome_desktop_Tabular_Content_EuiDataGrid_Custom_Header_Content.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+112 KB
...loki/reference/chrome_desktop_Tabular_Content_EuiDataGrid_Draggable_Columns.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
...s/eui/.loki/reference/chrome_desktop_Tabular_Content_EuiDataGrid_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-78 Bytes
(100%)
...i/.loki/reference/chrome_desktop_Tabular_Content_EuiDataGrid_Virtualization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4 Bytes
(100%)
...reference/chrome_desktop_Tabular_Content_EuiDataGrid_gridStyle_prop_Compact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
...eference/chrome_desktop_Tabular_Content_EuiDataGrid_gridStyle_prop_Expanded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1 Byte
(100%)
.../chrome_desktop_Tabular_Content_EuiDataGrid_gridStyle_prop_Horizontal_Lines.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1 Byte
(100%)
...reference/chrome_desktop_Tabular_Content_EuiDataGrid_gridStyle_prop_Minimal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
...erence/chrome_desktop_Tabular_Content_EuiDataGrid_gridStyle_prop_Playground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1 Byte
(100%)
...ence/chrome_desktop_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
...sktop_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Custom_Line_Height.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3 Bytes
(100%)
...ontent_EuiDataGrid_rowHeightsOptions_prop_Custom_Line_Height_Control_Column.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1 Byte
(100%)
...sktop_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Custom_Row_Heights.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3 Bytes
(100%)
...hrome_desktop_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Line_Count.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-8 Bytes
(100%)
...ome_desktop_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Line_Count_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1 Byte
(100%)
...me_desktop_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Static_Height.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+437 Bytes
(100%)
..._desktop_Tabular_Content_EuiDataGrid_toolbarVisibility_prop_Column_Selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+705 Bytes
(110%)
...e_desktop_Tabular_Content_EuiDataGrid_toolbarVisibility_prop_Column_Sorting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2 Bytes
(100%)
...hrome_desktop_Tabular_Content_EuiDataGrid_toolbarVisibility_prop_No_Toolbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1 Byte
(100%)
...op_Tabular_Content_EuiDataGrid_toolbarVisibility_prop_Render_Custom_Toolbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1 Byte
(100%)
...bular_Content_EuiDataGrid_toolbarVisibility_prop_Toolbar_Visibility_Options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-62 Bytes
(100%)
.../eui/.loki/reference/chrome_mobile_Tabular_Content_EuiDataGrid_Cell_Actions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-64 Bytes
(100%)
.../reference/chrome_mobile_Tabular_Content_EuiDataGrid_Cell_Expansion_Popover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-73 Bytes
(100%)
...i/reference/chrome_mobile_Tabular_Content_EuiDataGrid_Custom_Header_Content.png
Oops, something went wrong.
Binary file added
BIN
+124 KB
....loki/reference/chrome_mobile_Tabular_Content_EuiDataGrid_Draggable_Columns.png
Oops, something went wrong.
Binary file modified
BIN
-61 Bytes
(100%)
...es/eui/.loki/reference/chrome_mobile_Tabular_Content_EuiDataGrid_Playground.png
Oops, something went wrong.
Binary file modified
BIN
-129 Bytes
(100%)
...ui/.loki/reference/chrome_mobile_Tabular_Content_EuiDataGrid_Virtualization.png
Oops, something went wrong.
Binary file modified
BIN
-45 Bytes
(100%)
.../reference/chrome_mobile_Tabular_Content_EuiDataGrid_gridStyle_prop_Compact.png
Oops, something went wrong.
Binary file modified
BIN
-34 Bytes
(100%)
...reference/chrome_mobile_Tabular_Content_EuiDataGrid_gridStyle_prop_Expanded.png
Oops, something went wrong.
Binary file modified
BIN
-49 Bytes
(100%)
...e/chrome_mobile_Tabular_Content_EuiDataGrid_gridStyle_prop_Horizontal_Lines.png
Oops, something went wrong.
Binary file modified
BIN
-65 Bytes
(100%)
.../reference/chrome_mobile_Tabular_Content_EuiDataGrid_gridStyle_prop_Minimal.png
Oops, something went wrong.
Binary file modified
BIN
-57 Bytes
(100%)
...ference/chrome_mobile_Tabular_Content_EuiDataGrid_gridStyle_prop_Playground.png
Oops, something went wrong.
Binary file modified
BIN
-82 Bytes
(100%)
...rence/chrome_mobile_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Auto.png
Oops, something went wrong.
Binary file modified
BIN
-89 Bytes
(100%)
...obile_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Custom_Line_Height.png
Oops, something went wrong.
Binary file modified
BIN
-95 Bytes
(100%)
...ontent_EuiDataGrid_rowHeightsOptions_prop_Custom_Line_Height_Control_Column.png
Oops, something went wrong.
Binary file modified
BIN
-87 Bytes
(100%)
...obile_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Custom_Row_Heights.png
Oops, something went wrong.
Binary file modified
BIN
-116 Bytes
(100%)
...chrome_mobile_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Line_Count.png
Oops, something went wrong.
Binary file modified
BIN
-53 Bytes
(100%)
...rome_mobile_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Line_Count_1.png
Oops, something went wrong.
Binary file modified
BIN
-88 Bytes
(100%)
...ome_mobile_Tabular_Content_EuiDataGrid_rowHeightsOptions_prop_Static_Height.png
Oops, something went wrong.
Binary file modified
BIN
+1.07 KB
(100%)
...e_mobile_Tabular_Content_EuiDataGrid_toolbarVisibility_prop_Column_Selector.png
Oops, something went wrong.
Binary file modified
BIN
+1.7 KB
(110%)
...me_mobile_Tabular_Content_EuiDataGrid_toolbarVisibility_prop_Column_Sorting.png
Oops, something went wrong.
Binary file modified
BIN
-80 Bytes
(100%)
...chrome_mobile_Tabular_Content_EuiDataGrid_toolbarVisibility_prop_No_Toolbar.png
Oops, something went wrong.
Binary file modified
BIN
-49 Bytes
(100%)
...le_Tabular_Content_EuiDataGrid_toolbarVisibility_prop_Render_Custom_Toolbar.png
Oops, something went wrong.
Binary file modified
BIN
-85 Bytes
(100%)
...bular_Content_EuiDataGrid_toolbarVisibility_prop_Toolbar_Visibility_Options.png
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - Added `columnVisibility.canDragAndDropColumns` on `EuiDataGrid` which enables reordering columns via draggable header cells | ||
|
|
87 changes: 87 additions & 0 deletions
87
packages/eui/src-docs/src/views/datagrid/schema_columns/column_dragging.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import React, { useState } from 'react'; | ||
| import { faker } from '@faker-js/faker'; | ||
|
|
||
| import { | ||
| EuiDataGrid, | ||
| EuiAvatar, | ||
| EuiToolTip, | ||
| EuiButtonIcon, | ||
| } from '../../../../../src/components'; | ||
|
|
||
| const CustomHeaderCell = ({ title }) => ( | ||
| <> | ||
| <span>{title}</span> | ||
| <EuiToolTip content="tooltip content"> | ||
| <EuiButtonIcon | ||
| iconType="questionInCircle" | ||
| aria-label="Additional information" | ||
| color="primary" | ||
| /> | ||
| </EuiToolTip> | ||
| </> | ||
| ); | ||
|
|
||
| const columns = [ | ||
| { | ||
| id: 'avatar', | ||
| initialWidth: 40, | ||
| isResizable: false, | ||
| actions: false, | ||
| }, | ||
| { | ||
| id: 'name', | ||
| displayAsText: 'Name', | ||
| display: <CustomHeaderCell title="Name" />, | ||
| }, | ||
| { | ||
| id: 'email', | ||
| display: <CustomHeaderCell title="Email" />, | ||
| }, | ||
| { | ||
| id: 'city', | ||
| }, | ||
| { | ||
| id: 'country', | ||
| }, | ||
| { | ||
| id: 'account', | ||
| }, | ||
| ]; | ||
|
|
||
| const data = []; | ||
|
|
||
| for (let i = 1; i < 5; i++) { | ||
| data.push({ | ||
| avatar: ( | ||
| <EuiAvatar | ||
| size="s" | ||
| name={`${faker.person.lastName()}, ${faker.person.firstName()}`} | ||
| /> | ||
| ), | ||
| name: `${faker.person.lastName()}, ${faker.person.firstName()} ${faker.person.suffix()}`, | ||
| email: faker.internet.email(), | ||
| city: faker.location.city(), | ||
| country: faker.location.country(), | ||
| account: faker.finance.accountNumber(), | ||
| }); | ||
| } | ||
|
|
||
| export default () => { | ||
| const [visibleColumns, setVisibleColumns] = useState( | ||
| columns.map(({ id }) => id) | ||
| ); | ||
|
|
||
| return ( | ||
| <EuiDataGrid | ||
| aria-label="DataGrid demonstrating column reordering on drag" | ||
| columns={columns} | ||
| columnVisibility={{ | ||
| visibleColumns: visibleColumns, | ||
| setVisibleColumns: setVisibleColumns, | ||
| canDragAndDropColumns: true, | ||
| }} | ||
| rowCount={data.length} | ||
| renderCellValue={({ rowIndex, columnId }) => data[rowIndex][columnId]} | ||
| /> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.