-
-
Notifications
You must be signed in to change notification settings - Fork 747
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
Fix drag events not moving indicator when staying in the same node #222
base: v0.1.x
Are you sure you want to change the base?
Fix drag events not moving indicator when staying in the same node #222
Conversation
✔️ Deploy Preview for craftjs ready! 🔨 Explore the source changes: 97cc9bc 🔍 Inspect the deploy log: https://app.netlify.com/sites/craftjs/deploys/610169c9ac30650008791d69 😎 Browse the preview: https://deploy-preview-222--craftjs.netlify.app |
onDragOver(x: number, y: number, targetId: NodeId) { | ||
const draggedElement = DefaultEventHandlers.draggedElement; | ||
if (!draggedElement) { | ||
return; | ||
} | ||
|
||
if (targetId) { | ||
const node = this.store.query.node(targetId).get(); | ||
if (!node) { | ||
return; | ||
} | ||
} | ||
|
||
let node = (draggedElement as unknown) as Node; | ||
|
||
if ((draggedElement as NodeTree).rootNodeId) { | ||
const nodeTree = draggedElement as NodeTree; | ||
node = nodeTree.nodes[nodeTree.rootNodeId]; | ||
} | ||
|
||
const indicator = this.store.query.getDropPlaceholder(node, targetId, { | ||
x, | ||
y, | ||
}); | ||
|
||
if (!indicator) { | ||
return; | ||
} | ||
this.store.actions.setIndicator(indicator); | ||
DefaultEventHandlers.indicator = indicator; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part seems to be the same as the dragenter
handler used in the drop
connector.
Can we rename this function to something like computeIndicator
, so we can use for both the dragover
and dragenter
handler?
On that note - perhaps we don't even need the dragenter
handler anymore, since this updated dragover
handler is doing the same thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any update on this?
Great work @nicoladefranceschi this is looks like its solving a core bug that has been nagging us for a while any chance of resolving this confilets before the next release? |
@hugominas sorry I'm quite busy right now, maybe someone else can take over and make the necessary changes so that this can be merged? |
I think I fixed the merge conflicts and added @prevwong suggestion to rename But... I cannot tell the difference between the before https://craft.js.org and the new behavior. Did I mess up while resolving the merge conflict? |
Hi @ankri thank you! To be honest after testing this PR locally I did not find any noticeable difference. I was facing a drag and dropping issue caused by the Elements not having enough space between them and I only realised this after. Probably @nicoladefranceschi can help us. |
all those PRs are pratically abandoned |
This pull request fixes a problem when dragging nodes.
Drag events are not moving indicator when the mouse is staying in the same node.
This gifs explain it better:
If the mouse moves on different nodes, it works as expected:
If you move the mouse staying in the same node, it doesn't work: