-
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
Edits to templates and template parts inside subfolders are not saved correctly #54279
Comments
The same problem happens for templates, not just parts. |
Adding this to 6.4 for triage. |
I'll be working on this here. If anyone would like to jump in please do: Further updates will be posted there. |
@getdave Thank you for the thorough testing and report. |
Summary of ProblemTL;DR
Recommendation: for now official documentation should be updated to advise Theme authors that they cannot use subdirectories within the More detail
Suggested FixI wonder whether we ought to abandon the idea of mapping filesystem path with template part post slug? Why?
Both of the above mean we cannot rely on slug to map to filesystem for nested paths. As a result we cannot reliably dedupe customized template parts from filesystem template parts. Therefore I propose we consider utilising post meta to store the original template part filesystem path. My understanding is that Post Meta is well suited to store information such as this. With this information stored against the TP Post record we can:
If we do this we should consider the findings about using slashes in Post Meta in this Trac ticket which I commented about. |
By chance, Sergey mentioned this trac ticket in a meeting this morning https://core.trac.wordpress.org/ticket/58132 |
One idea to resolve this might be to use a different character instead of a
Any character we use as a delimiter can also be used on the file system, so it can't be safely assumed to be a delimiter. |
Yes. That is interesting because that notes that using slashes in Post Meta can cause problems on some environments. So again we'd need to store some other known character in the meta to stand in for/represent a slash and then reverse engineer that when we want to get the "real" path for deduping. |
After a review by core editor triage leads and core editor tech leads, this has been removed from the board for 6.5 consideration. |
Tagging my previous #49100 as related. I'll close that as a duplicate because this ticket has activity. |
Description
Block themes can place template parts in subfolders inside the
parts
folder. (See previous issue: #20375)Changes made to these template parts are not saved as a user customization to that part.
Instead, it looks like a new template part is created, and there is something wrong with the saved state: the changes to the customized part show as not being saved.
Step-by-step reproduction instructions
Activate Twenty Twenty-Three.
Inside the parts folder, create a new folder called "headers".
Move header.html inside this folder.
In home.html, change
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
to<!-- wp:template-part {"slug":"headers/header","tagName":"header"} /-->
Confirm that the header template part loads correctly.
In the editor, select the header template part and make some changes. Either directly on the home template screen or in isolation -it doesn't matter.
Save.
Notice that the save seems complete, and the "Site updated" notification appears.
But the Save button is still in the state that shows that there are unsaved changes, and the site preview button next to it is disabled.
Click on the Icon in the top left corner of the Site Editor to open the navigation sidebar (the dark grey sidebar on the left side)
Confirm that the save button at the bottom of the sidebar is showing that there are unsaved changes.
Click on this save button.
Notice that the notification "Site update" shows up but the state doesn't change; it still shows that there are unsaved changes.
Using the sidebar, please navigate to the "All template parts" screen to view the list of template parts.
Notice that the headers/header template part added by the theme is not labeled as being customized.
Instead, there are multiple user-created template parts with the name
headers//header
in the list.Screenshots, screen recording, code snippet
(I only have mobile internet at the moment, I will upload a video later.)
Environment info
Tested on macOS, nginx, PHP 8.0.22 using:
WordPress 6.3.1 with and without Gutenberg 16.6.0.
WordPress 6.2.2
I did not test on versions older than 6.2.2.
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: