pragmatic-drag-and-drop icon indicating copy to clipboard operation
pragmatic-drag-and-drop copied to clipboard

Prevent flashing drop indicator between two nearest list item

Open zmirnes opened this issue 9 months ago • 7 comments

How to prevent drop indicator flashing when I drag item between list items?

https://github.com/user-attachments/assets/791e0396-b6d7-4406-86f9-ee2004dd6f6e

zmirnes avatar Feb 27 '25 12:02 zmirnes

Hey @zmirnes, can you please share a reproduction environment, such as a Codesandbox? Otherwise it's a bit difficult for us to help you :)

michaelabrahamian avatar Mar 05 '25 04:03 michaelabrahamian

If the flash is because of gaps between drop targets then stickiness could prevent this: https://atlassian.design/components/pragmatic-drag-and-drop/core-package/drop-targets#getissticky

dropTargetForElements({
    element: myElement,
    getIsSticky: () => true,
});

declan-warn avatar Mar 05 '25 05:03 declan-warn

Today I will share a reproduction environment to show what is problem.

zmirnes avatar Mar 06 '25 06:03 zmirnes

I also noticed this issue, seems to occur more in React 19, my current workaround is

onDragLeave() {
  // To prevent flickering drop inidcatior when dragging over the item
  requestAnimationFrame(() => {
    setState(idleState)
  })
},

piecyk avatar Apr 28 '25 09:04 piecyk

the same problem I use the code from the examples: https://atlassian.design/components/pragmatic-drag-and-drop/examples Tree

I also use the latest react > 19 getIsSticky: () => true, and requestAnimationFrame does not work

username14415 avatar May 13 '25 02:05 username14415

If the flash is because of gaps between drop targets then stickiness could prevent this: https://atlassian.design/components/pragmatic-drag-and-drop/core-package/drop-targets#getissticky

dropTargetForElements({ element: myElement, getIsSticky: () => true, });

This is what I was looking for, thanks!

jakub-gawlik avatar Sep 12 '25 22:09 jakub-gawlik

Neither the getIsSticky() nor the raf() works for me. I spent my 3 days just on this bug; still finding solution.

The examples are so complicated and convoluted that it is very hard to reduce the logic from them.

Krish-Das avatar Oct 13 '25 14:10 Krish-Das