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

contentOnly template lock can be lost #49048

Open
stokesman opened this issue Mar 13, 2023 · 5 comments
Open

contentOnly template lock can be lost #49048

stokesman opened this issue Mar 13, 2023 · 5 comments
Assignees
Labels
[Feature] Block Locking The API allowing for the ability to lock/unlock blocks [Type] Bug An existing feature does not function as intended

Comments

@stokesman
Copy link
Contributor

stokesman commented Mar 13, 2023

Description

When editing/modifying a block with templateLock: contentOnly it's possible to cause a loss of the attribute by updating while the editing mode is engaged. It’s happened to me at least once.

Step-by-step reproduction instructions

<!-- wp:group {"templateLock":"contentOnly","layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group"><!-- wp:list {"style":{"layout":{"selfStretch":"fixed","flexSize":"50%"}}} -->
<ul><!-- wp:list-item -->
<li>one</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>two</li>
<!-- /wp:list-item -->

<!-- wp:list-item -->
<li>three</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->

<!-- wp:image {"style":{"layout":{"selfStretch":"fill"}},"className":"is-style-default"} -->
<figure class="wp-block-image is-style-default"><img alt=""/></figure>
<!-- /wp:image --></div>
<!-- /wp:group -->
  1. In the Post Editor, paste the above code
  2. Select the Group (Row) block
  3. Pick “Modify” from the block “Options” menu
  4. (Optional, merely to enable the “Update” button) change content or a setting of the group or one of its children
  5. Update/save the post without first exiting the editing mode
  6. Refresh the editor
  7. Note that the block is no longer contentOnly

Screenshots, screen recording, code snippet

loss-of-contentOnly.mp4

Environment info

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

Yes

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

No

@stokesman stokesman added the [Type] Bug An existing feature does not function as intended label Mar 13, 2023
@Thelmachido Thelmachido added the Needs Decision Needs a decision to be actionable or relevant label Mar 14, 2023
@Thelmachido
Copy link

For now, users still have the freedom to leave this locked mode by pressing modify. When modify is pressed, the block editor shows the hierarchy, and the user has complete control. For now, any user can press the modify button. In the future, it may depend on the capabilities of the user.

Hi @stokesman when I click modify I can edit as well, however, following the conversation on locking updates you can opt-out of the locked mode by clicking modify on blocks.

Not sure this can be considered as a bug, looping in @jorgefilipecosta to review

@stokesman
Copy link
Contributor Author

Thank you @Thelmachido. Since I'm not sure I’ve made this clear I hope to clarify.

  1. It seems that pressing modify is intended to temporarily unlock the block.
  2. Saving the post before disengaging the mode saves the block with the lock removed.

My expectation is that pressing modify to unlock the block is not part of its savable state. Among the things supporting that expectation is that it does not create entry in the history stack, i.e. it's not an edit.

@Thelmachido Thelmachido added Needs Technical Feedback Needs testing from a developer perspective. and removed Needs Decision Needs a decision to be actionable or relevant labels Mar 15, 2023
@franzaurus
Copy link

franzaurus commented Mar 20, 2023

I think I understand what @stokesman mean.

I find that the contentOnly lock mode disengagement issue only came up if I reload the Post Editor without first clicking "Done" on the said locked block after modifying it.

Perhaps this issue could be counted as a bug or at least a usability issue.

Steps to reproduce

  1. Edit a block with contentOnly locked
  2. Click "Modify"
  3. Edit the content e.g the text or change its background color
  4. Click "Update"
  5. Without clicking "Done" on the locked block, reload the Post Editor
  6. Observe the contentOnly locked block is now a regular (unlocked) block

The issue, however, doesn't happen if on step 5 I managed to click "Done" after modifying the said locked block because doing so will preserve the lock.

Environment
WordPress 6.2 RC2, TT3 theme without Gutenberg installed.
WordPress 6.1.1, TT3 with Gutenberg 15.3.1 installed.

Modify the contentOnly locked block without clicking "Done" afterwards.

reload-page-content-only-editing-wp-62-rc2

Modify the contentOnly locked block and click "Done" afterwards.

content-only-editing-wp-62-rc2

@jorgefilipecosta jorgefilipecosta self-assigned this Mar 24, 2023
@jorgefilipecosta
Copy link
Member

This seems like a bug, ideally, when pressing save we would revert the block back to content locked before saving.

@talldan
Copy link
Contributor

talldan commented Apr 11, 2023

Pressing 'Modify' unsets the contentLock attribute, and 'Done' sets it back again. So when saving content lock will be made inactive unless you click 'Done' first.

I think the best thing would be for 'modify' not to change the block attribute, instead it could set a value that isn't persisted (either a useState value or something in the block-editor store).

@talldan talldan added [Feature] Block Locking The API allowing for the ability to lock/unlock blocks and removed Needs Technical Feedback Needs testing from a developer perspective. labels Apr 11, 2023
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] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants