Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a sortable grid correctly #166

Open
hungify opened this issue Dec 17, 2024 · 3 comments
Open

Implement a sortable grid correctly #166

hungify opened this issue Dec 17, 2024 · 3 comments

Comments

@hungify
Copy link

hungify commented Dec 17, 2024

Hello there!
pragmatic-reorder.netlify.app

Here’s a simpler version: Repo, but there are some flicker UI issues to address.

What’s the correct way to handle this situation? If anyone has any suggestions, I’d love to hear them! Thank you!

@sno6
Copy link

sno6 commented Dec 18, 2024

Drive-by comment (was checking the issues while implementing the package).

I had some strange behaviour in React when I didn't return the cleanup function returned from functions such as combine(), monitorForElements(), dropTargetForElements(). Not too familiar with Vue but I imagine it functions similarly.

@hungify
Copy link
Author

hungify commented Dec 18, 2024

Issue 1: The onDropTargetChange event executes unnecessarily multiple times.

  1. Event Flow:
    • When you drag Item A to the position of Item B, the onDropTargetChange event fires and performs a reorder list
    • After reordering, Items A and B swapped places, but the library detected that their positions had changed relative to each other.
    • Re-trigger enters and leaves events again (A “leaves” B and then “enters” its new position; similarly for B).
  2. Consequence:
    • The onDropTargetChange event fires again after the list has already been reordered.

=> Infinity loop: https://github.com/user-attachments/assets/fade32e4-f875-490e-a8d9-5f60669efb77

@hungify
Copy link
Author

hungify commented Dec 18, 2024

@sno6
Make sure to carefully follow up on the React example provided by the author.

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

No branches or pull requests

2 participants