Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix: Impossible to drag & drop blocks if locking is insert #14521
If the CPT locking is set to insert it should be possible to move the blocks. Currently, it is possible to move the blocks using the block move buttons but not possible using drag & drop.
This PR fixes the problem of being impossible to use drag & drop when locking equals insert.
How has this been tested?
I pasted the contents of this gist https://gist.github.com/jorgefilipecosta/b50b090932b22bff1abe193fd0f5d649 in the functions.php file of the theme enable on my test website. I verified I can move the blocks using drag & drop while on master that is not possible.
Apr 12, 2019
requested review from
Apr 12, 2019
nosolosw left a comment
This indeed renders the dropzone, but when dropping the block in another place it doesn't work - blocks stay in the same position.
I've also checked that changing the
Hi @nosolosw, it seems my analysis was wrong. This PR is not dependent on #14924. The condition to make this move work was already part of the moveBlockToPosition function. The problem was that fromRootClientId was '' and toRootClientId was undefined so the condition fromRootClientId === toRootClientId did not matched. I updated the code to make things work as expected, and this PR should fix the problem on its own.
OK, this is what I've found: testing with the example provided works as described.
I also wanted to test how this behaves with inner blocks, so I've added
I guess we can prepare a different PR for fixing the
referenced this pull request
May 2, 2019
Hi @nosolosw, this seems like the expected behavior given how locking inheritance works.
A block inherits the locking from the parent if locking was not explicitly set.
So I think given the inheritance logic we don't have any issue in the template_lock=all.
That restriction happens and the move is not possible because there is a locking insert on root level. #14924 addresses another issue where the move is allowed if we don't have locking on the root level, but we have locking insert in a child block.
This logic is complex, I hope I managed to summarize it, but If I missed something in my explanation feel free to comment and I will expand.
nosolosw left a comment •
Works as expected and the code is fine.
I can repro in