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

Fix drag events not moving indicator when staying in the same node #222

Open
wants to merge 3 commits into
base: v0.1.x
Choose a base branch
from

Conversation

nicoladefranceschi
Copy link

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:
craftjs_bug_1

If you move the mouse staying in the same node, it doesn't work:
craftjs_bug_2

@netlify
Copy link

netlify bot commented Mar 19, 2021

✔️ 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

Comment on lines 22 to 52
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;
}
Copy link
Owner

@prevwong prevwong Apr 22, 2021

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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any update on this?

@hugominas
Copy link

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?

@nicoladefranceschi
Copy link
Author

@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?

@ankri
Copy link
Collaborator

ankri commented Jul 28, 2021

I think I fixed the merge conflicts and added @prevwong suggestion to rename onDragOver to computeDragIndicator.

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?

The old DefaultHandler.ts

@hugominas
Copy link

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.

@prevwong prevwong changed the base branch from develop to v0.1.x November 15, 2021 10:45
@leandroruel
Copy link

all those PRs are pratically abandoned

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 this pull request may close these issues.

6 participants