-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Ensure replacing a template part using a pattern doesn't update the existing entity #44221
Ensure replacing a template part using a pattern doesn't update the existing entity #44221
Conversation
Size Change: -28 B (0%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tested well for me. I see that replacing the template blocks when selecting a pattern was a deliberate design decision initially (here and here), but as you note it seems like this approach makes more sense, because the current approach could result in the inadvertent overwriting of template content in templates that are used in multiple places.
I just cherry-picked this PR to the wp/6.1 branch to get it included in the next release: 69597b9 |
What?
Fixes the comment here - #41397 (comment), see also #44147
Why?
As mentioned in the above issue comment, it can be confusing that selecting a template part creates a new entity, while selecting a pattern replaces the blocks in the existing entity.
This can also be destructive if the user didn't intend to update the entity. A template part can be used across multiple templates, so it would result in unexpectedly widespread changes.
How?
Remarkably the fix is to delete some code. There was a specific code path added to replace the template part's blocks, but I removed this in favour of the same behavior the template part's placeholder has - creating a new entity and setting that entity as active.
Testing Instructions
Screenshots or screencast
Before
Kapture.2022-09-16.at.16.23.41.mp4
After
Kapture.2022-09-16.at.16.21.07.mp4