-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Attempting to rename Template Part deletes Template Part #24000
Comments
Does #23661 fix it? |
Possibly related: #22639 |
No. Interestingly, I can only reproduce this bug with the template parts created by the Full Site Editing Demo Templates experiment. If I create a new Template Part, I have no trouble renaming it, even after a save and refresh. |
The issue also happens with Template Parts provided by a block-based theme, so I think the issue may have something to do with the difference between those and user-created Template Parts. |
Interesting, I am able to reproduce as well without demo-templates. It seems that the renaming is problematic if we haven't saved a custom version of the template part. Template part disappears when:
Does not have an issue when:
|
I guess once you edit and save the content of a template part originally provided by a theme, it stops being sourced from the theme since its been modified, so I guess that's why renaming works afterwards. |
Right.. something along those lines. So initially the theme references the template part by a name and has a template-part file with that name. When we change the name to something else, the file with that new name is not found and the template part disappears from the editor. When we edit the template part first and 'save', the Template is also updated and saved to reference the new template part cpt with a given ID. So when that name is updated it still has the ID to display the template part. |
Renaming it needs to save as well then. |
Or maybe we shouldn't allow renaming if it's not saved? Or a more elegant way of handling this? I feel like the forcing a save is going to be problematic? It would need to save the template part and template as soon as the user types into the name input. If there are already changes dirtied in the template or template part the forced save would either overwrite those changes to only save the new TP name / how the template references it, or will save all those other dirty changes without user confirmation? Either case seems problematic. Perhaps what needs to happen is in the case that the Template Part is being referenced by |
Good points. That sounds like a sensible solution. |
Perhaps a theme-supplied template part should be in read-only mode by default, with a button exposed to enable customizing it. Upon pressing this button, a user-created clone of the template part will be created and the block will be updated to reference the user one rather than the theme one. That makes the action a bit more explicit, which makes it clearer that you're no longer using the unmodified theme template part. |
I would expect to be able to rename a template part without hitting save until I am ready. I expect the template part to remain in place with the new name. |
Should we just delay persistent changes to the title until clicking save? Doesn't it currently update the actual title in the DB just when typing in the field? |
If it is currently updating the DB immediately upon typing, then that's inefficient, and it should definitely be changed to only happen upon save. |
I think whats happening is when you type in to change the name, it uses |
Edit - I think #24500 has a good working fix now.
I am noticing once I go to 'save', the template part can be replaced with a different auto-draft template part of the same initial slug. It seems like its an issue with the template saving with It works as expected when:
It can replace with a different auto-drafted template part by the same slug when:
|
Describe the bug
When trying to edit the template part name, the entire template section is removed. cc @epiqueras since this might be resolved with your PR #23661
To reproduce
Steps to reproduce the behavior:
Expected behavior
I expected the template part to be renamed.
Screenshots
Here's a video of me walking through this (44 seconds): https://cloudup.com/cc_RpdQWy8F
Editor version (please complete the following information):
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: