Skip to content

Enhance drag-and-drop experience with SortableGrid and TouchDragOverlay#43

Merged
sumitsahoo merged 4 commits intomainfrom
dev
Apr 11, 2026
Merged

Enhance drag-and-drop experience with SortableGrid and TouchDragOverlay#43
sumitsahoo merged 4 commits intomainfrom
dev

Conversation

@sumitsahoo
Copy link
Copy Markdown
Owner

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 SortableGrid component 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:

  • Added a new SortableGrid component 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.tsx src/components/SortableGrid.tsxR1-R122)
  • Introduced a TouchDragOverlay component to show a floating preview of the dragged item under the finger during touch drags, improving mobile UX. (src/components/TouchDragOverlay.tsx src/components/TouchDragOverlay.tsxR1-R36)
  • Refactored the useSortableDrag hook to unify drag and touch handlers via getItemProps, track the current touch position for overlays, and export a SortableDrag type for easier integration with components like SortableGrid. (src/hooks/useSortableDrag.ts [1] [2] [3] [4] [5] [6] [7] [8]
  • Updated the "Add Blank Page" tool to use SortableGrid and 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:

  • Improved the logo in the Layout component by adding a smooth filter transition and supporting dynamic color filters via badgeAccent.logoFilter. (src/components/Layout.tsx src/components/Layout.tsxL105-R111)
  • Ensured the window scrolls to the top whenever the active tool or privacy view changes, enhancing navigation experience. (src/App.tsx src/App.tsxR698-R703)

These changes collectively make the page reordering experience more robust, user-friendly, and maintainable, especially across different device types.

- 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.
Copilot AI review requested due to automatic review settings April 11, 2026 08:34
@sumitsahoo sumitsahoo merged commit 6878c12 into main Apr 11, 2026
6 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 + TouchDragOverlay components to standardize drag/drop grids and touch previews.
  • Refactored useSortableDrag to unify desktop/touch wiring via getItemProps and to track touch coordinates for overlays.
  • Updated AddBlankPage, DuplicatePage, and ReorderPages tools to use SortableGrid; minor UX polish in Layout and scroll-to-top behavior in App.

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
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
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.

2 participants