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

columns block: add support for templateLock attribute #49132

Conversation

sque89
Copy link
Contributor

@sque89 sque89 commented Mar 16, 2023

What?

Add templateLock attribute and pass it into the innerBlockProps. fixes #48620

Why?

Theme developers can control the content editors abilities to create blocks with the InnerBlocks template and templateLock attribute. But currently it is not possible to reset the templateLock on a core/columns block, which prevents the editor from duplicating an existing column

How?

By adding support for the templateLock attribute to the core/columns block, the developers has a finer control over locked templates.

Testing Instructions

  1. create a custom block which makes use of the InnerBlocks component
  2. add templateLock: 'insert' to the InnerBlocks component
  3. add a template to the InnerBlocks which contains a core/columns block with a column
  4. set the templateLock attribute of the columns block to false
  5. check that the column within the columns block can be duplicated

Testing Instructions for Keyboard

Screenshots or screencast

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Mar 16, 2023
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @sque89! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@Mamaduka Mamaduka added [Block] Columns Affects the Columns Block [Feature] Block Locking The API allowing for the ability to lock/unlock blocks labels Mar 16, 2023
@Mamaduka Mamaduka requested a review from t-hamano March 16, 2023 10:51
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR, @sque89!

As far as I have tested, everything is working as expected. Personally, I think it would be good to also add e2e tests on template_lock for the column block, as is already done in the group block, but can be addressed as a follow-up PR.

The following is my test in this PR:

Apply templateLock="all" to core/columns block

  • Should not be able to change the number of columns, add, delete, or move core/column block
  • The UI to change the number of columns should not appear
  • should not be able to insert a block inside core/column block
templateLock_all.mp4

Apply templateLock="insert" to core/columns block

  • Should not be able to add, delete core/column block
  • Should be able to move core/column block
  • The UI to change the number of columns should not appear
  • should not be able to insert a block inside core/column block
templateLock_insert.mp4

Apply templateLock="contentOnly" to core/columns block

  • Should not be able to change the number of columns, add, delete, or move core/column block
  • The UI to change the number of columns should not appear
  • Should only be able to edit the content within core/column block
templateLock_contentOnly.mp4

Apply templateLock=false to core/columns block, Apply templateLock="insert" to parent group block

  • Should not be able to delete the core/columns block in the group block
  • Should be able to move the core/columns block in the group block
  • In the core/columns block, all operations should be possible.
templateLock_to_group.mp4

@t-hamano t-hamano merged commit 22ca90c into WordPress:trunk Mar 21, 2023
@github-actions
Copy link

Congratulations on your first merged pull request, @sque89! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts:

https://profiles.wordpress.org/me/profile/edit/

And if you don't have a WordPress.org account, you can create one on this page:

https://login.wordpress.org/register

Kudos!

@github-actions github-actions bot added this to the Gutenberg 15.5 milestone Mar 21, 2023
@sque89 sque89 deleted the fix/columns-block-not-supporting-template-lock branch March 21, 2023 16:11
@femkreations femkreations added the Needs User Documentation Needs new user documentation label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Columns Affects the Columns Block [Feature] Block Locking The API allowing for the ability to lock/unlock blocks First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository Needs User Documentation Needs new user documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

core/columns not supporting templateLock
4 participants