-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix dirty template and template parts on template creation. #26560
Conversation
Size Change: +104 B (0%) Total Size: 1.21 MB
ℹ️ View Unchanged
|
It looks like the |
There still seems to be another innerBlocks update happening after we consider them loaded in the case of the new template flow. 🤔 |
This seems to be working now. 😁 |
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.
✨
Description
This PR fixes a bug where creating a new Template from the navigation sidebar in the site editor loads the template with all the un-customized theme supplied template-parts dirtied and upgraded to 'publish' status.
This bug is fixed by refactoring the
useEffect
in the template part block to rely on inner blocks changing from when they were initially loaded, as opposed to the previous implementation of relying on a magic number of innerBlocks updates. Previously, the first 2 innerBlocks updates were ignored and the 3rd innerBlocks update would assume a user editing the contents of the template part to triggersetAttribute( postId )
andeditEntityRecord
to upgrade status topublish
. 2 seems to be a magic number that worked for loading an existing template in the site editor, but it seems this does not work for the new template creation flow. Instead of allowing this to happen on the n-th update, we allow it to happen on the 1st update to innerBlocks content after innerBlocks are considered to be loaded.How has this been tested?
In the Site Editor:
Screenshots
Types of changes
Checklist: