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

While in a LOCKED template, a core/group block set to 'templateLock' => false will lose priority, upon publishing #29799

Closed
amarinediary opened this issue Mar 11, 2021 · 4 comments · Fixed by #29916
Assignees
Labels
[Block] Group Affects the Group Block (and row, stack and grid variants) [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@amarinediary
Copy link
Contributor

Description

While in a LOCKED template, a core/group block set to 'templateLock' => false will lose priority/reset to true, upon publishing preventing the user from modifying any child block under the core/group block.

Step-by-step reproduction instructions

  1. Define a 'template' => [ ... ] on an existing or new post type, custom or not.
  2. Locked out the template PRIOR to calling the 'template'.
//...
'template_lock' => 'all',
'template' => [ ... ]
//...
  1. Add a core/group block to the template and set 'templateLock' => false.
  2. Add multiple core/paragraph blocks or else.
//...
'template_lock' => 'all',
'template' => [
    [ 'core/group', [ 'templateLock' => false, 'className' => 'myCustomClass', ], [
        [ 'core/paragraph', ],
        [ 'core/paragraph', ],
        [ 'core/paragraph', ],
    ], ],
],
//...
  1. From the admin panel, navigate to your post type and add a new post.
  2. You should be able add blocks or switch existing core/paragraph blocks to any blocks. Add a title publish, leave and come back.
  3. You won't be able to add a new block nor to switch to an existing one. A warning will be displayed that the template as change.

Expected behaviour

Ideally, core/group blocks should have their own environment, and not be affected by the global template behaviour. The ability to insert or switch blocks within the core/group block should remain if set to 'templateLock' => false. Behaviour within a core/group should only depend on the 'templateLock' attribute.

Actual behaviour

Upon publishing, the 'template_lock' => 'all' takes priority over the core/block 'templateLock' => false. You won't be able to add a new block nor to switch to an existing one. A warning will be displayed that the template as change.

Screenshots or screen recording (optional)

Vv3z9ZnFBF

WordPress information

  • WordPress version: 5.7
  • Gutenberg version: 9.3-9.9
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? No

Device information

  • Device: MacBook Air (13-inch, 2017)
  • Operating system: macOS Mojave
  • Browser: Version 89.0.4389.82 (Official Build) (x86_64)
@amarinediary
Copy link
Contributor Author

Additionally, if 'template_lock' => 'all', is set AFTER 'template', the core/group 'templateLock' => false attribute will just get ignored.

@talldan
Copy link
Contributor

talldan commented Mar 12, 2021

@amarinediary Ah, right, I think this is because template_lock in the group block needs to be a string:
https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/group/block.json#L11

Does it work if you use the value 'false'?

@amarinediary
Copy link
Contributor Author

amarinediary commented Mar 12, 2021

@talldan With template attribute 'template_lock' => 'all' and core/group attribute 'templateLock' => 'false' the block is permanently locked. 'templateLock' => 'false' is just getting ignored.

@talldan
Copy link
Contributor

talldan commented Mar 15, 2021

Ok, thanks for reporting, this seems like a bug then.

@talldan talldan added [Block] Group Affects the Group Block (and row, stack and grid variants) [Type] Bug An existing feature does not function as intended labels Mar 17, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Group Affects the Group Block (and row, stack and grid variants) [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants