Skip to content

Use dnd-kit sortable context for scrollable reordering#13

Closed
0suu wants to merge 1 commit into
suu/10-sort-device-listfrom
codex/add-scroll-support-while-sorting-in-dnd-kit-rbcq5p
Closed

Use dnd-kit sortable context for scrollable reordering#13
0suu wants to merge 1 commit into
suu/10-sort-device-listfrom
codex/add-scroll-support-while-sorting-in-dnd-kit-rbcq5p

Conversation

@0suu

@0suu 0suu commented Nov 26, 2025

Copy link
Copy Markdown
Owner

Summary

  • add dnd-kit dependencies for sortable drag interactions
  • migrate device and scene reorder flows to dnd-kit while retaining wheel-based scrolling during drags

Testing

  • not run (new dependencies could not be installed in the current environment)

Codex Task

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @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 dnd-kit library. This change aims to provide a more stable and maintainable drag-and-drop experience, while ensuring that existing user interactions, such as scrolling during a drag, remain functional.

Highlights

  • Dependency Update: Added @dnd-kit/core, @dnd-kit/sortable, and @dnd-kit/utilities to package.json to enable the new drag-and-drop functionality.
  • Reordering Logic Migration: The drag-and-drop reordering logic for both devices and scenes has been migrated from a custom implementation to use the dnd-kit library, enhancing robustness and maintainability.
  • Refactored Components: Introduced SortableDeviceCard and SortableSceneCard components to encapsulate the dnd-kit specific drag-and-drop behavior for individual items, improving code organization and reusability.
  • User Experience Preservation: The new dnd-kit implementation is configured to retain wheel-based scrolling during drag operations, ensuring a consistent user experience.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
outline: dragOverId === scene.sceneId || isOver ? "2px solid" : "none",
outline: isOver ? "2px solid" : "none",

boxShadow: 1,
pointerEvents: "none",
}}
aria-label={"Reorder"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The aria-label is hardcoded as "Reorder". Since the t function for translation is passed as a prop, it should be used here to support internationalization, consistent with how it's handled in SortableDeviceCard.

Suggested change
aria-label={"Reorder"}
aria-label={t("Reorder")}

@0suu 0suu closed this Nov 26, 2025
@0suu 0suu deleted the codex/add-scroll-support-while-sorting-in-dnd-kit-rbcq5p branch December 29, 2025 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant