-
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
Edit Site: Avoid dirtying un-customized templates on first load. #22876
Edit Site: Avoid dirtying un-customized templates on first load. #22876
Conversation
Size Change: +816 B (0%) Total Size: 1.12 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.
I don't think this is quite working for me:
- Template Parts are still dirty (I know this isn't the goal of the PR, but would still be nice to solve)
- The first edit to a template part dirties the template as well. (probably because of the template part ID being set?)
It seems like the solution here is just deferring the problem, so I wonder if there is a more robust way to solve it.
I tested this by cleaning my environment and re-enabling the FSE experiment & templates before testing
When?
Yes, this is still a clear improvement over |
On loading the editor with non-customized template parts (same situation as when the template would be dirtied). Obviously none of this is an issue once we are loading from CPTs.
I think I'm onboard with this if we fix the same problem with template parts. Otherwise, it's not really noticeable that anything has been improved, since a dirty state is still visible when entering the editor for the first time... So on load, I get: Dirtied: template part Then, I modify the template part and I get: Dirtied: template and template part This is confusing behavior to me, and I feel like the template & template part being dirty the whole time makes more sense, in a way. The other thing is that I assume if we fix the problem in a more robust way, then we wouldn't need this workaround |
Fixed :) |
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.
Nice! works for me. Now the editor shows no dirty changes until you actually modify something, so it at least looks like expected behavior now.
This is a really cool one. It fixes one of the most important bugs in the current flows. |
Description
This PR stops uncustomized templates from becoming dirty just by being loaded in the site editor. It does this by ensuring template parts don't persist a post ID unless they've been edited, and by deferring the site editor's initial status and title template edits to the entities saved states callback, which is now called right before saving.
How has this been tested?
It was verified that loading the site editor on a template without saved customizations, that contains template parts, does not make it dirty.
Checklist: