-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[DataGrid] Add column reorder support #165
Conversation
packages/grid/x-grid-modules/src/components/styled-wrappers/grid-root.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-grid-modules/src/components/styled-wrappers/grid-root.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-grid-modules/src/hooks/features/useColumnReorder.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-grid-modules/src/hooks/features/useColumnReorder.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-grid-modules/src/hooks/features/useColumnReorder.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-grid-modules/src/hooks/features/useColumnReorder.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-grid-modules/src/hooks/features/useColumnReorder.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-grid-modules/src/hooks/features/useColumnReorder.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-grid-modules/src/hooks/features/useColumnReorder.tsx
Outdated
Show resolved
Hide resolved
packages/grid/x-grid-modules/src/hooks/features/useColumnReorder.tsx
Outdated
Show resolved
Hide resolved
Also I had a look at the UX and I think it needs to be improved. |
packages/grid/x-grid-modules/src/components/column-header-item.tsx
Outdated
Show resolved
Hide resolved
I would also include the documentation. We start to have enough infrastructure on the X repository to be able to work incremental with the documentation and tests as part of each pull request, I think that we should leverage it :). |
Can you guys recheck the PR when you have time? |
fb4eb9e
to
33f6bd5
Compare
Opportunities we have identified during yesterday's peer programming session:
|
…ort for the ColumnsHeader
…ld fail if its not the case
…rget, remove potential confusion
All good from my end. I have pushed individual commits for improvement opportunities I could notice (spend about 1 hour on this). Feedback welcomed them. For the follow-up issues we could open:
|
packages/grid/_modules_/grid/hooks/features/useColumnReorder.tsx
Outdated
Show resolved
Hide resolved
b81d2a1
to
5274172
Compare
* [useColumnReorder] Add the ability to reorder columns using drag and drop * [useColumnReorder] Fix review comments * fix broking functionality * Fix issues related to pulling the latest changes * {useColumnReorder] Refactor the feature hook and add drag scroll support for the ColumnsHeader * [useColumnReorder] Fix lint and format issues * [useColumnsReorder] Fix build and formatting * [useColumnReorder] Fix lint errors * Fix styles downgrade when dragging a column cell * [useColumnReorder] Added option to disable the feature, added docs, added tests * [useColumnReorder] Fix formatting and enable all the tests * Remove unnessesary code from the mouse.test.ts file * Fix formatting * fix formatting * Emit event when drag enters a column * Working on PR comments * Fix inifinte loop when dragging smaller cal over large col * Rename drag handlers prefix * Prep codebase for commit and push * Run prettier * Fix lint errors * Rename file to match coding style * Rename columnsHeaderRef to ref * Fix PR comments * Update docs/pages/api-docs/x-grid.md Co-authored-by: Matt <[email protected]> * Update docs/pages/api-docs/x-grid.md Co-authored-by: Matt <[email protected]> * Update docs/pages/api-docs/x-grid.md Co-authored-by: Matt <[email protected]> * Add relevant documentation about coumn reorder on the /components/data-grid/columns/ page * Fix docs formatting * Update docs/src/pages/components/data-grid/columns/columns.md Co-authored-by: Olivier Tassinari <[email protected]> * Update docs/src/pages/components/data-grid/columns/columns.md Co-authored-by: Olivier Tassinari <[email protected]> * Update docs/src/pages/components/data-grid/columns/columns.md Co-authored-by: Olivier Tassinari <[email protected]> * Update docs/src/pages/components/data-grid/columns/columns.md Co-authored-by: Olivier Tassinari <[email protected]> * Update code example * Fix PR comments * Fix the doc example code * Update docs/src/pages/components/data-grid/columns/ColumnOrderingGrid.tsx Co-authored-by: Olivier Tassinari <[email protected]> * Fix column reordering issue while dragging over the same cell * Make scrolling while dragging excelerate * Format and lint the changes * Fix scroll left issue * Fix build * fix scroll smoothness * Fix Col header item alignment visuall regression * Final polishing of the useColumnReorder hook * Fix typings * the logic never runs on Node.js * clear timeout when unmounting, avoid edge-case leak * use design token * no shorthand * Use CSS inherit * simpler class name logic * we have strong constraint that these value should be defined. It should fail if its not the case * no shorthands * the logic depends on the element to be the current target, not the target, remove potential confusion * add visual clue about where the column is, outline shouldn't be visible * Remove unnecessary checks related to disableColumnReorder flag * Fix PR comments related * remove raf Co-authored-by: Matt <[email protected]> Co-authored-by: Olivier Tassinari <[email protected]> Co-authored-by: Danail Hadzhiatanasov <[email protected]>
This PR adds the functionality to reorder data grid columns by dragging and dropping them. It achieves this by utilizing the HTML5 drag and drop API.
The functionality was done by following how similar features were added, e.g
useColumnResize
. I've added a new hook in the features folder calleduseColumnResize
and inside it is the logic needed for this feature to work.In addition, I added one CSS class with styles inside the
styled-wrappers/grid-root.tsx
file.Unit tests are missing from this PR.
Please leave your feedback regarding the implementation and when we have an agreement I'll add the needed unit tests (and probably documentation)
Closes #194