-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
Row dragging capabilities #616
Conversation
Update changelog & release new version
Update changelog & release new version
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
i need this feature, can anyone please merge? |
This definitely implements a really useful piece of functionality that has been requested by user before. The only thing that really bothers me is that we'd need to add I'm thinking perhaps we should reserve this for a new major release... Otherwise we'd make lot of applications break if users will update their deps without realizing that we have introduced a new dependency. Or maybe we could find a way to make the dependency optional, so that only users who need DnD are forced to install it?... I'm really curious to hear other people's feedback on this before making a decision. |
Update docs, README, CHANGELOG
Bump version
Wouldn't it be possible to make the drag and drop functionality an extra module that a user can install alongside the mantine-datatable package? Essentially making it an opt-in package that then would use the @hello-pangea/dnd dependency but then the user is explicitly installing this for the reason of using the functionality. Another idea I have, but would have to be tested pretty well, is to install the I'll take some time to research optional dependencies and modules for packages. |
Also, I would like to point out that installing In case you value keeping dependency count manageable |
change link @hello-pangea/dnd on example page change structure this row dragging feature Add row factory feature to Data Table
i fixed dependency on this commit |
I like the idea of rowFactory, I have a suggestion to improve this
in this way its usage will be something similar to <DataTable
//other props
rowFactory={({ record, index, trProps, children }) => (
<Draggable key={record.id} draggableId={record.id} index={index}>
{(provided) => (
<Table.Tr
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
{...trProps}
>
{/** add a td for drag handle (optional) */}
{children}
</Table.Tr>
)}
</Draggable>
)}
/>; any comments? |
yes its ok |
so in previous solution if user scrolls in table while dragging, it disrupts the calculation of dnd library, to tackle that issue I've added tableWrapper prop to add a wrapper inside scrollarea
@mehdiraized I did some change in your code, and update example as well, any comments on it? |
no i haven't any comment |
@icflorescu can we add this feature? |
Looks fantastic, thanks, @MohdAhmad1! |
package/DataTableRow.tsx
Outdated
style={{ | ||
cursor: 'grab', | ||
|
||
width: '50px', |
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.
To be honest, I'm not 100% happy with the default 50px
width. Ideally the drag handle column should take as little space as possible.
Not sure if #625 is a direct result of this merge but wanted to see your thoughts on that @icflorescu since the behavior wasn't broken before |
Isn't there any other solution to implement the row reorder? |
we just added rowFactory props |
I think the thing here is that even if you only use 1 feature of the package, it still pulls in all peer dependencies. I think row re-ordering is easily achieved without having to implement an entire library. Especially when people like me would not use the row re-ordering functionality and yet I now have to pull in the extra dependency if I were to udate to the latest version |
And to just mention this, I did say in a previous comment that this will pull in a lot of extra deps: #616 (comment) |
I agree with you @mikkurogue @mehdiraized you're right but if we plan to make this reorder feature the lib agnostic then we should at least build this feature with two different dnd libraries to prove that it works perfectly without any unforeseen issue. |
i can't understanding what is problem |
you say if you update to last version mantine-datatable we automatically added @hello-pangea/dnd package to your project |
yeah after checking you are right, it should not include the @hello-pangea/dnd package by itself. I do still think a native solution is still probably better, as this feature then doesn't introduce dnd functionality, just introduces the ability to implement it yourself (so to speak) |
if we can add this feature by other packages |
Agreed, but then I think its a different discussion to use gpt/claude/copilot to generate the implementation (Im a certified copilot refuser so I'm biased). I think, personally the value of a feature request shouldn't lie in an abstract "we allow you to implement it yourself" when the functionality people want is usually the same. End of the day its icflorescu's call, but I still do doubt the value of this introduction when it just exposes an API to implement it yourself (unless I'm misunderstanding this) |
This feature is not about me |
I think you're misunderstanding what I'm saying. The contribution is fine, but I feel its disingenous to call it a feature when it doesnt introduce any new functionality outside of allowing a user to hook their own library into the factory. As much as it is cool, it certainly doesn't feel like it's the way forward for the library to introduce new features if it still boils down to me having to still implement it myself at the end of the day. I agree complex features should work very simply, but the question then is; what do you classify as a complex feature? Any drag and drop I don't consider complex (a pain sometimes). Personally I don't think a library that delivers functionality shouldn't expose an API to the user to introduce external functionality, at that point it's just forking the repo with extra steps |
This PR introduces row dragging capabilities to the Mantine Datatable component. This feature was developed to meet a requirement in our organization and can benefit the wider Mantine community by providing an intuitive way to reorder rows within the datatable.
closes #513
Key Features:
onDragEnd
to handle custom logic after the drag-and-drop process.Implementation Details:
Documentation:
We believe this enhancement will significantly improve the flexibility and usability of the Mantine Datatable component. We welcome any feedback and suggestions for further improvements. Thank you for considering this PR.