Long tap does not work after drag-and-drop#2847
Long tap does not work after drag-and-drop#2847raineorshine merged 8 commits intocybersemics:mainfrom
Conversation
…ss of the dragged thought
…show quick drop panel and alert
|
Thanks for the PR! Before I can evaluate the proposed solution, please provide a thorough description of the cause of the bug. Then, an explanation of why this solution is the best way to address it. In particular, you will need to |
Cause of the issue:The issue with long press in drag and drop functionality is caused by a lock mechanism that's not being properly reset: In Problem: During drag operations, the normal flow is interrupted. Result: The lock remains true, blocking all subsequent long press attempts This explains why we can't immediately long-press a thought after a drag operation. The solution is to reset the lock in the endDrag function. In short we are not adding new state but rather reseting a global lock via custom dispatching method. |
|
Thank you, I appreciate the explanation.
I'd like to drill down on this a bit more. You're saying that when a drag ends, The way I see it, Hopefully I'm not missing something, but that's the question I have currently.
You're right, sorry I mischaracterized it! It is a new dispatching method, not new state. |
Yes you are actually right about event propagation being prevented thing. I spent some time researching about the internals of react dnd and here's what i found out. React DnD intercepts touch/mouse events during drag, blocking useLongPress.stop from running. It captures touchend/mouseup and stops propagation, preventing the lock reset. As a result, lock remains true, blocking future long presses. So the only solution that came in find is to manually reset the lock when the drag process ends. Since we are maintaining a global lock in the |
|
Okay, that explains it. react-dnd breaks From a complexity perspective this is unfortunate, as it forces us to tightly couple Now that we have identified the root cause, note that the problem is bigger than just A few other points:
|
Changes Made As Per Discussion
|
raineorshine
left a comment
There was a problem hiding this comment.
Hmmm... I'm not sure how we got to this point. My first comments were about avoiding additional state. You reassured me by pointing out that you were just introducing a new dispatch method to change the long press lock from a different module. Now we have longPressStore.isLocked, longPressStore.isLongPressing, onLongPressEndRef, and wasLongPressingRef (and that's not including the existing globals.longpressing). This is a lot of state for a long press hook. I think you need to rethink your approach and find a lighter solution.
There was a problem hiding this comment.
The test says that it shows the alert and quick drop panels, but they don't appear in the snapshot.
I have refactored the ministore pattern to opt in for single state variable that controls the locking behavior while long press |
raineorshine
left a comment
There was a problem hiding this comment.
This looks much better! Thanks.
I think it may be possible to consolidate globals.longpressing, but that is out of scope for this issue. It will be good to do it in a separate PR anyway for more granular regression tracking.
Problem
Solution
Testing: Added end-to-end tests to verify long press interactions and drag-and-drop behavior.
issue: #2090