Skip to content

Add touch/mobile support for wish list drag and drop#29

Merged
JoeProgrammer88 merged 2 commits intomainfrom
copilot/fix-mobile-wishlist-drag-drop
Mar 2, 2026
Merged

Add touch/mobile support for wish list drag and drop#29
JoeProgrammer88 merged 2 commits intomainfrom
copilot/fix-mobile-wishlist-drag-drop

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 2, 2026

The wish list reordering relied solely on the HTML5 Drag & Drop API, which has no touch support, making reordering impossible on mobile devices.

Changes

  • Touch event handlers added to each wish list item in renderWishList():
    • touchstart — captures source item ID, applies dragging class
    • touchmove (passive: false) — suppresses scroll, uses elementFromPoint (with transient visibility hide) to detect drop target, efficiently tracks previously highlighted item to avoid per-frame querySelectorAll
    • touchend — resolves final drop target and executes the same reorder logic as the mouse drop handler
let touchDragOverItem: HTMLElement | null = null;
el.addEventListener('touchstart', () => {
    this.dragSrcWishId = el.dataset.wishId!;
    el.classList.add('dragging');
}, { passive: false });
el.addEventListener('touchmove', (e) => {
    e.preventDefault();
    const touch = e.touches[0];
    el.style.visibility = 'hidden';
    const target = document.elementFromPoint(touch.clientX, touch.clientY);
    el.style.visibility = '';
    const targetItem = target?.closest<HTMLElement>('.wish-item') ?? null;
    if (targetItem !== touchDragOverItem) {
        touchDragOverItem?.classList.remove('drag-over');
        touchDragOverItem = targetItem !== el ? targetItem : null;
        touchDragOverItem?.classList.add('drag-over');
    }
}, { passive: false });

Mouse drag and drop is unchanged.

Original prompt

This section details on the original issue you should resolve

<issue_title>Wish list drag and drop on mobile</issue_title>
<issue_description>The wish list items drag and drop on mobile does not currently work</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: JoeProgrammer88 <7156063+JoeProgrammer88@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix wish list drag and drop functionality on mobile Add touch/mobile support for wish list drag and drop Mar 2, 2026
@JoeProgrammer88 JoeProgrammer88 marked this pull request as ready for review March 2, 2026 18:59
@JoeProgrammer88 JoeProgrammer88 merged commit 49b4f6c into main Mar 2, 2026
1 check passed
@JoeProgrammer88 JoeProgrammer88 deleted the copilot/fix-mobile-wishlist-drag-drop branch March 2, 2026 19:00
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.

Wish list drag and drop on mobile

2 participants