-
Notifications
You must be signed in to change notification settings - Fork 23
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
refactor: [DHIS2-17650] Replace Material-UI Table, TableBody, TableCell, TableHead and TableRow #3721
refactor: [DHIS2-17650] Replace Material-UI Table, TableBody, TableCell, TableHead and TableRow #3721
Conversation
…_ReplaceMaterialUIComponentsInDragAndDropTableColumnSelector
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.
LGTM!
🚀 Deployed on https://deploy-preview-3721--dhis2-capture.netlify.app |
…_ReplaceMaterialUIComponentsInDragAndDropTableColumnSelector
This reverts commit c609f1a.
@eirikhaugstulen requested some changes to improve usability, so I have implemented them now. Note: I can see that the hover effect can be confusing under drag, but I found it hard to fix it. Would you give me another review with the new changes implemented @simonadomnisoru? Thanks! |
cardTarget, | ||
connect => ({ connectDropTarget: connect.dropTarget() }), | ||
)(Index)); | ||
const opacity = isDragging ? 0.5 : 1; |
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.
Note: I can see that the hover effect can be confusing under drag, but I found it hard to fix it.
How about setting the opacity to 0
when dragging? This way the drawn row will look empty and can help with the confusion of the hover effect (this is also how it currently works in play with the material UI components).
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.
@simonadomnisoru
I agree that setting the opacity to 0
makes it better so I will change it to:
const opacity = isDragging ? 0 : 1;
However, the table row hover is still confusing. I added a picture where I am dragging the Gender, but the hover is marking Last name.
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 use Firefox where the hover issue doesn't happen, but I was able to reproduce it in Chrome. I bealive you can remove the hover styles altogether with something like this in the DragDropListItem.component.js
.
// the styles
const styles = {
rowWithoutHover: {
'&:hover > td': {
backgroundColor: 'transparent !important',
},
},
};
// and in the render use the class
return (
<DataTableRow ref={ref} style={{ opacity }} className={classes.rowWithoutHover} draggable>
<DataTableCell>{text}</DataTableCell>
......
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.
Thank you, @simonadomnisoru! That works. With the changes, the hover was completely removed, so in addition to your suggested changes, I added a state to tell if any element in the list is being dragged. Based on that state, I will disable the hover. What do you think? I appreciate your help!
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.
It looks great now 👏
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.
Great work @henrikmv!
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.
Tested successfully on 2.42 version
🎉 This PR is included in version 100.77.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
DHIS2-17650
DndProvider
was expecting the div, I got this error message: Only native element nodes can now be passed to React DnD connectors. You can either wrap DataTableRow into a div or turn it into a drag source or a drop target itself. Solved by using useRef to set theDataTableRow
to ref.