Skip to content

Fix input focus loss in GroupCommandList#22

Merged
kubrickcode merged 1 commit intomainfrom
sortable-focus-bug
Sep 20, 2025
Merged

Fix input focus loss in GroupCommandList#22
kubrickcode merged 1 commit intomainfrom
sortable-focus-bug

Conversation

@kubrickcode
Copy link
Owner

@kubrickcode kubrickcode commented Sep 20, 2025

Replace useSortableList hook with direct DndContext implementation to prevent DOM recreation during renders.

issue #19

@kubrickcode kubrickcode self-assigned this Sep 20, 2025
@gemini-code-assist
Copy link

Summary of Changes

Hello @kubrickcode, 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 addresses a critical user experience issue in the GroupCommandList component where input focus was lost during interactions. The solution involves a significant refactoring of the drag-and-drop functionality, moving from a custom useSortableList hook to a direct integration of @dnd-kit's DndContext and SortableContext. This change ensures that the DOM elements are not unnecessarily recreated, thereby preserving input focus and providing a smoother user interaction.

Highlights

  • Refactor Drag-and-Drop Implementation: The custom useSortableList hook has been replaced with a direct integration of @dnd-kit's DndContext and SortableContext for managing drag-and-drop functionality.
  • Prevent DOM Recreation: The new drag-and-drop implementation prevents unnecessary DOM element recreation during renders, which was the root cause of the input focus loss issue.
  • Fix Input Focus Loss: This change resolves the problem where input focus was lost when interacting with sortable items within the GroupCommandList component, improving 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

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.

@kubrickcode kubrickcode changed the title Fix input focus loss in GroupCommandList #19 Fix input focus loss in GroupCommandList Sep 20, 2025
@kubrickcode
Copy link
Owner Author

/gemini review

Copy link

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

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 correctly addresses the input focus loss issue by refactoring the drag-and-drop implementation. Instead of using a custom hook that returned a new component on each render, the DndContext is now implemented directly within the GroupCommandList component. This prevents unnecessary re-mounting of components and preserves input focus. I've added a suggestion to make the index validation in handleDragEnd safer.

Copy link

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

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 addresses the input focus loss issue by replacing the useSortableList hook with a direct DndContext implementation, which prevents the component tree from being recreated on each render. The changes are well-structured. I've added a couple of comments: one high-severity suggestion to prevent potential state and focus issues related to list reordering by using stable keys, and one medium-severity suggestion to improve the robustness of the drag-and-drop handler logic. Overall, this is a good improvement.

Replace useSortableList hook with direct DndContext implementation to prevent DOM recreation during renders.
@kubrickcode kubrickcode merged commit 6ba1efc into main Sep 20, 2025
2 checks passed
@kubrickcode kubrickcode deleted the sortable-focus-bug branch October 6, 2025 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant