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

[4.x]: Drag and drop not working on Neo child blocks #12896

Closed
chrismlusk opened this issue Mar 15, 2023 · 7 comments
Closed

[4.x]: Drag and drop not working on Neo child blocks #12896

chrismlusk opened this issue Mar 15, 2023 · 7 comments
Assignees

Comments

@chrismlusk
Copy link

chrismlusk commented Mar 15, 2023

What happened?

Description

When attempting to grab a Neo child block and reorder it, the entire parent block is grabbed instead.

An issue was opened in the Neo repo, but it was closed with an assumption that it is a Craft bug.

However, I tested with Matrix fields, and I can drag and drop child blocks as expected. Even a Matrix field within a Neo block works, too.

So, it might not be a Craft bug, but I wanted to open an issue just in case.

Craft CMS version

4.4.1

Installed plugins and versions

  • Neo: 3.7.1
@ttempleton
Copy link

Extra context: I had assumed it's a Craft bug because it worked properly with Craft 4.3. I've just done some quick testing and found that it was working as late as 4.4.0-beta.4 and specifically seems to have been introduced with a6eeabf.

@i-just
Copy link
Contributor

i-just commented Mar 16, 2023

Hi, thanks for reporting and for the additional info. I created a PR to fix this.

@brandonkelly
Copy link
Member

3.8.3 and 4.4.3 are out with the fix!

@engram-design
Copy link
Contributor

engram-design commented May 17, 2023

Just FYI, this has broken Navigation (just for Craft 3) which uses a manual structure setup. Refer to verbb/navigation#348 We revamped the navigation builder in Craft 4, so it's not an issue there. We render Navigation nodes within a fake element index, rather than constructing things ourselves, manually like in Craft 3.

What I don't quite understand is the thinking here, because according to StructureDrag.js you can have multiple selectors for the handles of the drag trigger:

this.base($items, {
    handle: '.element:first, .move:first',
    helper: this.getHelper.bind(this),
});

Because this has been changed to use only first() on this selector, it means only .element:first works, which is exactly what we're seeing. Removing the change made in 66ae85b fixes our issue.

To put this visually, you can see the difference when calling:

console.log($(this.settings.handle, item));
console.log($(this.settings.handle, item).first());
image

So the .move:first selector never actually gets registered with the BaseDrag class, and therefore the StructureDrag that we use. Dragging will only work when dragging the element, not the drag handle.

image

I'm looking into how this still seems to work for Sections which use the structure layout, so it's certainly a Navigation-specific thing, but I'm sure others might be using the StructureDrag component.

Of course, none of this has to do with the Neo issue listed here, which I'm not across.

@i-just
Copy link
Contributor

i-just commented May 18, 2023

@engram-design I have a few ideas on this; we’ll discuss it internally, and I’ll get back to you.

@brandonkelly
Copy link
Member

@engram-design We released Craft 3.8.12 today with a fix for that 🎉

@engram-design
Copy link
Contributor

Seems to have sorted it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants