Skip to content

[bug] Continuous item reordering issue in grid layout when dragging the first item to the end of a row #2439

@wonhyo-e

Description

@wonhyo-e

Note: This issue description was drafted with assistance from an AI. Please excuse any formatting inconsistencies😅

Describe the bug
When using a grid layout, there's an issue with the first item in each row. When dragging the first item towards the last position in the row, other items in the same row continuously swap positions back and forth, creating a flickering effect. This happens consistently and makes it difficult to place the item in the desired position.

To Reproduce

  1. Create a grid layout with multiple items per row (2 or more columns)
  2. Click and drag the first item in a row
  3. Try to move it to the last position in the same row
  4. Observe how other items in the row continuously swap positions back and forth

Expected behavior
Items should maintain stable positions during dragging, and only swap when the dragged item passes the threshold for repositioning. There should be no continuous back-and-forth repositioning of other items.

Information
Versions - Look in your package.json for this information:
sortablejs = ^1.15.6
@types/sortablejs = ^1

Additional context

  • This issue occurs in the official grid examples as well
  • The problem is reproducible across different browsers and devices
  • The issue is more noticeable on mobile devices with smaller screens

Reproduction
This issue can be easily reproduced using the official grid example at https://sortablejs.github.io/Sortable/#grid
Steps to reproduce with the official example:

  • Visit https://sortablejs.github.io/Sortable/#grid
  • Reduce your browser window width until the items display in 2-3 columns per row
  • Click and hold on the first item in any row (e.g., item 1)
  • Drag it towards the end position of the same row
  • Observe how other items in the row continuously swap positions back and forth as you approach the end of the row
sortable_grid_error_2_converted.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions