You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Custom post type lock breaks block recovery #49005
The expected behaviour is to recovery the block. However this is not possible due to a lock.
But recovery does not insert new block. It just replace the existing one with same attributes. The lock check should be bypassed in this case.
When a template is locked, we should probably do a more granular check inside canInsertBlockTypeUnmemoized. Maybe something similar to validateBlocksToTemplate.
When a template is locked, we should probably do a more granular check inside canInsertBlockTypeUnmemoized. Maybe something similar to validateBlocksToTemplate.
Yeah, it's a difficult one to solve. canInsertBlockType has no knowledge of the block being replaced, it just knows that the parent block is locked and so we can't insert the recovered block.
Maybe introducing a canReplaceBlock selector that does a slightly different check and accounts for block validity, would be the way forwards.
An observation - I notice that when an invalid block has 'prevent removal' active, it can still be recovered 🤔
Still reproduces on trunk (recovery does nothing under a template lock, works without one). This is the same root cause as #25216, so closing as a duplicate to keep it in one place.
Activity
Tropicalista commentedon Mar 11, 2023
The expected behaviour is to recovery the block. However this is not possible due to a lock.
But recovery does not insert new block. It just replace the existing one with same attributes. The lock check should be bypassed in this case.
Mamaduka commentedon Mar 15, 2023
I can reproduce the issue.
When a template is locked, we should probably do a more granular check inside
canInsertBlockTypeUnmemoized. Maybe something similar tovalidateBlocksToTemplate.talldan commentedon Mar 15, 2023
Yeah, it's a difficult one to solve.
canInsertBlockTypehas no knowledge of the block being replaced, it just knows that the parent block is locked and so we can't insert the recovered block.Maybe introducing a
canReplaceBlockselector that does a slightly different check and accounts for block validity, would be the way forwards.An observation - I notice that when an invalid block has 'prevent removal' active, it can still be recovered 🤔
Tropicalista commentedon Mar 15, 2023
@talldan exactly what I was thinking: introduce a canReplaceBlock can also be used to insert pattern.
For example if pattern selected match root block, it will be replaced, otherwise skipped.
Another solution can be to introduce a block limit count on post type that will act as a locker.
youknowriad commentedon Sep 17, 2026
Still reproduces on trunk (recovery does nothing under a template lock, works without one). This is the same root cause as #25216, so closing as a duplicate to keep it in one place.