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

Partially locked template wrongly shows notice about template mismatch #44231

Open
kraftner opened this issue Sep 16, 2022 · 3 comments
Open
Labels
[Feature] Block Locking The API allowing for the ability to lock/unlock blocks [Type] Enhancement A suggestion for improvement.

Comments

@kraftner
Copy link

Description

If a template of a post is only partially locked only the locked sections should be compared with the template for mismatches.

An example:

We have a custom post type with a template and a locked root via 'template_lock' => 'all'. But a group block inside that post is unlocked by e.g. setting 'templateLock' => false.

As soon as another block is added inside that group the block editor thinks the content doesn't match the locked template and shows this notice:

grafik

But if a template intentionally makes some inner block areas editable changes to that area should be fine.


The problems seems to be that on the top level unlocked templates are considered.

// Unlocked templates are considered always valid because they act
// as default values only.

But this same behavior is not implemented in nested blocks.

I'd assume that at this point

return (
name === block.name &&
doBlocksMatchTemplate( block.innerBlocks, innerBlocksTemplate )
);

additional checks for unlocked blocks (e.g. for block.attributes.templateLock === false) should be added, ignoring everything inside unlocked blocks.

Step-by-step reproduction instructions

  1. Register a custom post type with
    • a template
    • template_lock set to all
    • unlock a block with inner blocks (e.g. core/group) inside the template by setting 'templateLock' => false on it
  2. Create a new post of that custom post type
  3. Add new blocks inside the unlocked block
  4. Save
  5. Reload
  6. See the notice which doesn't make sense

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 6.0.2 (without Gutenberg)

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@artemiomorales artemiomorales added Needs Testing Needs further testing to be confirmed. [Feature] Block Locking The API allowing for the ability to lock/unlock blocks [Type] Enhancement A suggestion for improvement. labels Sep 19, 2022
@Thelmachido
Copy link

Hi @kraftner thank you for giving a detailed report on this one, can you please confirm that the issue is persistent on the recent version of WordPress and Gutenberg?

@kraftner
Copy link
Author

@Thelmachido Yes.

I just tried it with WordPress 6.0.2 and Gutenberg 14.1.1 on a fresh install. Same issue.

(Wasn't expecting anything else since the current code referenced above still has the issue.)

@mrfoxtalbot mrfoxtalbot removed the Needs Testing Needs further testing to be confirmed. label Sep 26, 2022
@kraftner
Copy link
Author

I just wanted to bump this and confirm that the issue still exists at least in WP 6.3.3. Looking at the code that hasn't changed since I reported this issue I am assuming it is also still present in the 6.4 branch and trunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Locking The API allowing for the ability to lock/unlock blocks [Type] Enhancement A suggestion for improvement.
4 participants