Use dnd-kit sortable context for scrollable reordering#13
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 refactors the drag-and-drop reordering capabilities within the application. It transitions the underlying mechanism for reordering devices and scenes from a custom solution 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 effectively migrates the reordering functionality to dnd-kit, which is a great improvement for maintainability and user experience. The code is well-structured, with the introduction of SortableDeviceCard and SortableSceneCard components. My review includes a few suggestions to simplify the logic within these new components and fix a minor internationalization issue.
However, the testing notes mention that the changes have not been run due to dependency issues. It is critical to resolve these environment problems and thoroughly test the new drag-and-drop functionality on both mouse and touch devices before merging to ensure there are no regressions or unexpected behaviors.
| ref={setNodeRef} | ||
| sx={{ | ||
| position: "relative", | ||
| opacity: isDragging || draggingId === device.deviceId ? 0.5 : 1, |
There was a problem hiding this comment.
The condition draggingId === device.deviceId is redundant here. The isDragging boolean from the useSortable hook already correctly identifies if this is the item being dragged. Using isDragging alone is cleaner and more idiomatic when working with dnd-kit.
| 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.
Similar to the opacity property, the condition dragOverId === device.deviceId is redundant. The isOver boolean from useSortable is the idiomatic way to check if a dragged item is currently over this sortable item. Simplifying this will make the code easier to maintain.
| outline: dragOverId === device.deviceId || isOver ? "2px solid" : "none", | |
| outline: isOver ? "2px solid" : "none", |
| ref={setNodeRef} | ||
| sx={{ | ||
| position: "relative", | ||
| opacity: isDragging || draggingId === scene.sceneId ? 0.5 : 1, |
There was a problem hiding this comment.
The condition draggingId === scene.sceneId is redundant. The isDragging boolean provided by the useSortable hook is sufficient to determine if this is the active dragged item. Relying on isDragging is the standard practice with dnd-kit and simplifies the component's logic.
| 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 dragOverId === scene.sceneId check is not necessary here. The isOver boolean from the useSortable hook already provides this information directly and is the idiomatic approach. Using isOver alone will make the code cleaner.
| outline: dragOverId === scene.sceneId || isOver ? "2px solid" : "none", | |
| outline: isOver ? "2px solid" : "none", |
| boxShadow: 1, | ||
| pointerEvents: "none", | ||
| }} | ||
| aria-label={"Reorder"} |
There was a problem hiding this comment.
Summary
Testing
Codex Task