Enhance drag-and-drop experience with SortableGrid and TouchDragOverlay#43
Merged
sumitsahoo merged 4 commits intomainfrom Apr 11, 2026
Merged
Enhance drag-and-drop experience with SortableGrid and TouchDragOverlay#43sumitsahoo merged 4 commits intomainfrom
sumitsahoo merged 4 commits intomainfrom
Conversation
- Added SortableGrid component to facilitate reusable drag-and-drop grid for item reordering. - Updated TouchDragOverlay to remove rotation for better alignment. - Refactored useSortableDrag hook to provide getItemProps for handling both HTML5 and touch events. - Integrated SortableGrid into AddBlankPage, DuplicatePage, and ReorderPages components for consistent drag-and-drop behavior. - Removed redundant drag-and-drop logic from AddBlankPage and DuplicatePage, leveraging SortableGrid instead.
… filter transition
There was a problem hiding this comment.
Pull request overview
This PR refactors the page reordering / insertion UIs to use a shared drag-and-drop implementation that supports both desktop HTML5 drag and mobile touch drags, with improved visual feedback via a touch-following overlay.
Changes:
- Added reusable
SortableGrid+TouchDragOverlaycomponents to standardize drag/drop grids and touch previews. - Refactored
useSortableDragto unify desktop/touch wiring viagetItemPropsand to track touch coordinates for overlays. - Updated
AddBlankPage,DuplicatePage, andReorderPagestools to useSortableGrid; minor UX polish inLayoutand scroll-to-top behavior inApp.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/tools/ReorderPages.tsx | Migrates reorder UI to SortableGrid with overlay preview. |
| src/tools/DuplicatePage.tsx | Migrates duplicate/reorder UI to SortableGrid, keeps conditional drag behavior for originals. |
| src/tools/AddBlankPage.tsx | Migrates blank-page insertion/reorder UI to SortableGrid with overlay support. |
| src/hooks/useSortableDrag.ts | Unifies drag props via getItemProps and adds touch position tracking for overlays. |
| src/components/SortableGrid.tsx | New shared interleaved drop-zone + item renderer for sortable grids. |
| src/components/TouchDragOverlay.tsx | New portal-based overlay that follows the finger during touch drags. |
| src/components/Layout.tsx | Adds filter transition + optional badgeAccent.logoFilter support for logos. |
| src/App.tsx | Scrolls window to top when active tool / privacy view changes. |
| }, []); | ||
|
|
||
| /** Scroll to top whenever the view changes. */ | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps -- activeTool and showPrivacy are intentional trigger deps |
There was a problem hiding this comment.
The react-hooks/exhaustive-deps suppression looks unnecessary here since the effect already lists the intended dependencies (activeTool, showPrivacy). Consider removing the eslint-disable comment to avoid masking real dependency issues in future edits.
Suggested change
| // eslint-disable-next-line react-hooks/exhaustive-deps -- activeTool and showPrivacy are intentional trigger deps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a significant refactor and enhancement to the drag-and-drop page reordering feature, particularly in the "Add Blank Page" tool. The changes add a new reusable
SortableGridcomponent for handling drag-and-drop (including mobile touch support), streamline the drag logic, and improve user experience with visual feedback. Additionally, there are minor UI improvements elsewhere.Drag-and-drop reordering improvements:
SortableGridcomponent that provides a reusable, accessible drag-and-drop grid for page reordering, supporting both desktop and mobile touch events. This component manages drop-zones, drag overlays, and integrates with a new drag state bag. (src/components/SortableGrid.tsxsrc/components/SortableGrid.tsxR1-R122)TouchDragOverlaycomponent to show a floating preview of the dragged item under the finger during touch drags, improving mobile UX. (src/components/TouchDragOverlay.tsxsrc/components/TouchDragOverlay.tsxR1-R36)useSortableDraghook to unify drag and touch handlers viagetItemProps, track the current touch position for overlays, and export aSortableDragtype for easier integration with components likeSortableGrid. (src/hooks/useSortableDrag.ts[1] [2] [3] [4] [5] [6] [7] [8]SortableGridand the new drag state, removing the previous manual drag-and-drop logic and simplifying the component. (src/tools/AddBlankPage.tsx[1] [2] [3] [4] [5] [6]User interface improvements:
Layoutcomponent by adding a smooth filter transition and supporting dynamic color filters viabadgeAccent.logoFilter. (src/components/Layout.tsxsrc/components/Layout.tsxL105-R111)src/App.tsxsrc/App.tsxR698-R703)These changes collectively make the page reordering experience more robust, user-friendly, and maintainable, especially across different device types.