-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add columns reordering example #2007
Conversation
stories/demos/ColumnsReordering.tsx
Outdated
|
||
const reorderedColumns = columns.map(c => { | ||
if (c === sourceColumn) return targetColumn; | ||
if (c === targetColumn) return sourceColumn; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make more sense to move the dragged column before the target column?
I think the usual behavior when dragging things is to move them around rather than swap two objects around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I will update it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-Authored-By: Nicolas Stepien <[email protected]>
Co-Authored-By: Nicolas Stepien <[email protected]>
Co-Authored-By: Nicolas Stepien <[email protected]>
@@ -0,0 +1,57 @@ | |||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just not sure about this file. What do you guys think if we provide this in the DataGrid and export this as a default DraggableHeaderRenderer
?
pros: consumer devs can just use the default column function;
cons: 1. we might need to provide more APIs. 2. We have to include the react-dnd as a dependency...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep the dependencies to a minimum and provide a flexible API so users can write their own implementations. Composition is always more maintainable than adding extra props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's extra work to maintain the feature + dependency on other libs.
That way users can use whatever implementation they want to header dragging.
import { useDrag, useDrop, DragObjectWithType } from 'react-dnd'; | ||
|
||
import { HeaderRendererProps } from '../../../../src'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we don't need this empty line.
No description provided.