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

Bug with moving items breakpoints #2053

Open
Ale9600 opened this issue Jul 2, 2024 · 2 comments · May be fixed by #2070
Open

Bug with moving items breakpoints #2053

Ale9600 opened this issue Jul 2, 2024 · 2 comments · May be fixed by #2070

Comments

@Ale9600
Copy link

Ale9600 commented Jul 2, 2024

Describe the bug

In certain conditions items breakpoints are not coherent with expected behaviour when dragging elements. Breakpoints when items are considered moved is broken when you try to move a smaller block over a big one

Your Example Website or App

https://react-grid-layout.github.io/react-grid-layout/examples/0-showcase.html

Steps to Reproduce the Bug or Issue

  1. Get any of the demo or try directly on it
  2. (Start it)
  3. Put a smaller block on top of a big one
  4. Try to drag the smaller block over the big one from up to down and watch when the elements move, it seems that the breakpoint for the movement is far too low(not expected)
  5. Do the same but from down to up(it works fine)
  6. Do the same with an equal block( it works just fine in both directions)

Expected behavior

I think the behaviour of the elements should be the same independently of items size.

react-grid-layout library version

1.4.1

Operating System Version

macOS

Browser

Chrome

Additional context

No response

Screenshots or Videos

No response

@MaxMusing
Copy link
Contributor

MaxMusing commented Jul 8, 2024

Here's a video showing the issue:

Screenshot.2024-07-08.16.19.05.mp4

The breakpoint for vertically swapping items is too low. It feels like the breakpoint should instead be at the midpoint of the old and new positions:

Screenshot 2024-07-08 16 25 58@2x

In other words, try to place the item at the nearest possible position to where it's being hovered.

@michaelnesen
Copy link

michaelnesen commented Jul 31, 2024

Experiencing the same problem, appears to be some undesired behaviour with the collision detection movement

rgl-collision-detection-movement.mp4

I tried testing locally and following the movement logic, it looks like the issue occurs when a smaller element collides with a larger element from above in the grid layout. My hunch is that is the condition that handles collisions from above looks to move the element y 1 units in the grid, but with the smaller elements this doesn't seem to be enough to actually swap positions in the layout after compaction.

Based off the videos it appears the smaller item needs be way past the midpoint of the bigger element, ~ around 1 unit from the bottom until the two elements actually swap in the layout.

Any context on why this may be @STRML?

@michaelnesen michaelnesen linked a pull request Sep 6, 2024 that will close this issue
17 tasks
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 a pull request may close this issue.

3 participants