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

[QUESTION] Disable a block drag&drop #2744

Closed
jcze91 opened this issue Apr 28, 2020 · 3 comments
Closed

[QUESTION] Disable a block drag&drop #2744

jcze91 opened this issue Apr 28, 2020 · 3 comments

Comments

@jcze91
Copy link

jcze91 commented Apr 28, 2020

Hello everyone,

I would like to make forbidden the drop of one block before another specific one.
Context : i've create a new trait for some blocks to set them as "page header", and I don't want to allow the drag&drop one block before this "page header" as it must be the first block of my template.

I saw I could listen sorter:drag:validation event and update the valid property to false in this perspective. But I can't known the future order of the block I would drop.

So, I would be glad to know one solution to this problem.

Thanks in advance :)

@artf
Copy link
Member

artf commented Apr 29, 2020

From the latest release https://github.com/artf/grapesjs/releases/tag/v0.16.12 you can pass disable property to your block

@artf artf closed this as completed Apr 29, 2020
@jcze91
Copy link
Author

jcze91 commented Apr 29, 2020

Hello,
Thx for your response but it's not my use case.
I don't want to disable a block drag'n'drop on all the canvas, but I jus want this block to not to be added before another specific component.

@artf
Copy link
Member

artf commented May 4, 2020

You can see if you're able to achieve it with by using the draggable property (Component) or make use of block:drag:stop event to ensure if the dropped component meets the necessary criteria and remove it if it doesn't

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

No branches or pull requests

2 participants