contentOnly patterns: Fix lock icon appearing on toolbar when editing a section#73457
contentOnly patterns: Fix lock icon appearing on toolbar when editing a section#73457
Conversation
…k (block locking can disable template lock) - also un-shouldify the tests
| isMoveLocked: isMoveLockedBlock( clientId ), | ||
| isRemoveLocked: isRemoveLockedBlock( clientId ), | ||
| canLock: canLockBlockType( getBlockName( clientId ) ), | ||
| isContentLocked: getTemplateLock( clientId ) === 'contentOnly', |
There was a problem hiding this comment.
I couldn't see anywhere this is used, so it's deleted.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| 'has-single-cell': ! showBlockActions, | ||
| 'is-synced': blockInformation?.isSynced, | ||
| 'is-draggable': canMove, | ||
| 'is-draggable': canMoveBlock, |
There was a problem hiding this comment.
In some cases like this, it's correct to keep using the canMoveBlock selector. Now I use that selector directly instead of via the hook.
|
Size Change: +102 B (0%) Total Size: 2.54 MB
ℹ️ View Unchanged
|
BeforeKapture.2025-11-23.at.12.05.03.mp4AfterKapture.2025-11-23.at.12.06.59.mp4 |
ramonjd
left a comment
There was a problem hiding this comment.
Bug is fixed. Smoke tested locking/unlocking on trunk and on this branch.
I couldn't spot any regressions.
LGTM
andrewserong
left a comment
There was a problem hiding this comment.
Nicely done, this is testing great for me, too, and it makes a lot of sense having separate selectors for this 👍. The desired behaviour on trunk including locking all blocks inside, and unlocking some blocks within a parent locked block, is all still testing well for me, with the bug with spotlighted section blocks resolved.
One tiny question (not a blocker), in terms of naming, I was wondering if putting the word block earlier in the selector name would make it more consistent with some of the other isBlock selectors (like isBlockSelected)? So, isBlockEditLocked, rather than isEditLockedBlock. No strong opinions for me, so just a question 🙂
LGTM!
What?
Fixes #72159 - the block locking UI being displayed in cases where it shouldn't.
Why?
The bug happens because the block locking feature uses selectors like
canMoveBlockandcanRemoveBlock. These selectors are low level, and what the block editor uses as the source of truth for whether a block can be moved or removed. They reason about a wider range of systems that might prevent moving or removal, like block editing modes.A user can't change block editing modes from the block locking UI, so this shouldn't be something the block locking features incorporates into its locking logic.
How?
Introduces some new selectors that specifically reason about the types of locking the user can modify via the UI. Removes usage of selectors like
canMoveBlock,canRemoveBlockandcanEditBlockfor the locking feature.Testing Instructions
Do a general smoke test of block locking. Some gotchas about how the feature works in trunk (and maintained in this PR):
templateLock: 'insert'. It will also prevent block insertion, though it's not clear from the UI.Also test that the bug is fixed:
Screenshots or screencast
Kapture.2025-11-20.at.13.57.43.mp4