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
Describe the bug
Removing a Template Part from a page results in the Template Part edited to clear all inner content. This is a 'recent' regression in behavior. @noahtallen mentioned this is likely related to a recent PR of his (#21368 ).
To reproduce
Steps to reproduce the behavior:
Go to an Edtior (shown below is page editor) with full site editing experiment enabled.
insert a Template Part.
remove the template part.
notice the template part is 'dirty' in the save panel, and re-inserting will result in an empty template part.
Expected behavior
Expect the template part to not be dirtied on removal.
Screenshots
The text was updated successfully, but these errors were encountered:
Now that I think about it, #22586 will resolve this! 🥳
This is what causes the bug:
Removing the block triggers the remove block action in the block-editor store
The block-editor store removes all inner blocks of the given block
The useBlockSync hook for the the template part sees all of its inner blocks being removed and syncs those changes to the controlling entity.
The template part entity's content is wiped, triggering the dirty state (and saving will persist the wipe)
The useBlockSync hook "unsubscribes" now that the block associated with it is not in the editor.
So the solution is to "unsubscribe" from the changes a lot earlier. @epiqueras caught this as well in #22586, which cleans up that lingering subscription before it has a chance to cause issues.
Oh Nice! Im glad this has already been noticed and has a solution 😄
Addison-Stavlo
changed the title
Removing a Template Part dirty's the entity state with inner content removed.
Removing a Template Part dirties the entity state with inner content removed.
May 26, 2020
Describe the bug
Removing a Template Part from a page results in the Template Part edited to clear all inner content. This is a 'recent' regression in behavior. @noahtallen mentioned this is likely related to a recent PR of his (#21368 ).
To reproduce
Steps to reproduce the behavior:
Expected behavior
Expect the template part to not be dirtied on removal.
Screenshots
The text was updated successfully, but these errors were encountered: