Enable wheel scrolling during reorder with dnd-kit#15
Conversation
Summary of ChangesHello @0suu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the user experience for reordering devices and scenes by migrating the drag-and-drop logic to the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is a great improvement, replacing a manual drag-and-drop implementation with the dnd-kit library for reordering devices and scenes. This enhances maintainability and enables new features like wheel scrolling during drag operations. The code is well-structured, introducing new sortable components that cleanly encapsulate the drag-and-drop logic. My feedback consists of a few minor suggestions to remove some redundant logic and leftover code to further improve clarity. Overall, this is a solid and well-executed refactoring.
| {...listeners} | ||
| sx={{ | ||
| position: "relative", | ||
| opacity: isDragging || draggingId === device.deviceId ? 0.5 : 1, |
There was a problem hiding this comment.
The opacity style is conditional on isDragging || draggingId === device.deviceId. The isDragging property from the useSortable hook is sufficient to determine if the item is being dragged. Using draggingId from the parent component's state is redundant here and can be removed for clarity.
| opacity: isDragging || draggingId === device.deviceId ? 0.5 : 1, | |
| opacity: isDragging ? 0.5 : 1, |
| position: "relative", | ||
| opacity: isDragging || draggingId === device.deviceId ? 0.5 : 1, | ||
| transition: "opacity 0.2s ease", | ||
| outline: dragOverId === device.deviceId || isOver ? "2px solid" : "none", |
There was a problem hiding this comment.
The outline style is conditional on dragOverId === device.deviceId || isOver. The isOver property from the useSortable hook is sufficient to determine if a draggable item is over the current sortable item. Using dragOverId from the parent component's state is redundant here and can be removed for clarity.
| outline: dragOverId === device.deviceId || isOver ? "2px solid" : "none", | |
| outline: isOver ? "2px solid" : "none", |
| opacity: draggingId === device.deviceId ? 0.5 : 1, | ||
| transition: "opacity 0.2s ease", |
There was a problem hiding this comment.
In the rendering logic for when isReorderMode is false, the Box component has an opacity style that depends on draggingId. However, draggingId is only set when isReorderMode is true, so it will always be null in this case. This makes the opacity and transition styles redundant and they can be removed for clarity.
| {...listeners} | ||
| sx={{ | ||
| position: "relative", | ||
| opacity: isDragging || draggingId === scene.sceneId ? 0.5 : 1, |
There was a problem hiding this comment.
The opacity style is conditional on isDragging || draggingId === scene.sceneId. The isDragging property from the useSortable hook is sufficient to determine if the item is being dragged. Using draggingId from the parent component's state is redundant here and can be removed for clarity.
| opacity: isDragging || draggingId === scene.sceneId ? 0.5 : 1, | |
| opacity: isDragging ? 0.5 : 1, |
| position: "relative", | ||
| opacity: isDragging || draggingId === scene.sceneId ? 0.5 : 1, | ||
| transition: "opacity 0.2s ease", | ||
| outline: dragOverId === scene.sceneId || isOver ? "2px solid" : "none", |
There was a problem hiding this comment.
The outline style is conditional on dragOverId === scene.sceneId || isOver. The isOver property from the useSortable hook is sufficient to determine if a draggable item is over the current sortable item. Using dragOverId from the parent component's state is redundant here and can be removed for clarity.
| outline: dragOverId === scene.sceneId || isOver ? "2px solid" : "none", | |
| outline: isOver ? "2px solid" : "none", |
| opacity: draggingId === scene.sceneId ? 0.5 : 1, | ||
| transition: "opacity 0.2s ease", |
There was a problem hiding this comment.
In the rendering logic for when isReorderMode is false, the Box component has an opacity style that depends on draggingId. However, draggingId is only set when isReorderMode is true, so it will always be null in this case. This makes the opacity and transition styles redundant and they can be removed for clarity.
Summary
Testing
Codex Task