Fix visual indication of switch to default template in the post editor#57718
Merged
ntsekouras merged 4 commits intotrunkfrom Jan 17, 2024
Merged
Conversation
|
Size Change: +1.04 kB (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
This comment was marked as resolved.
This comment was marked as resolved.
youknowriad
reviewed
Jan 11, 2024
6067db6 to
690fc1e
Compare
youknowriad
reviewed
Jan 17, 2024
| 'postType', | ||
| 'wp_template', | ||
| defaultTemplateId | ||
| ); |
Contributor
There was a problem hiding this comment.
So one thing I noticed here is that this function is getting closer to use-init-edited-entity-from-url which is good.
The remaining difference is about the handling of the "posts page" and the "home page", both of these have special handling in the site editor that is not present here. I'm thinking that we might want to check these and unify these as well (probably a separate PR though)
youknowriad
approved these changes
Jan 17, 2024
Contributor
youknowriad
left a comment
There was a problem hiding this comment.
I confirm that this fixes both issues I was seeing:
- The draft pages not showing the right template in the site editor (theme 2024).
- The right template selected in the sidebar of the post editor when swapping templates.
I'd love if we can test some of these.
Contributor
Author
There is a test in post editor and a draft page already and I added one more for post editor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Fixes: #48577
When using the template switcher in the post editor sidebar to switch from a custom template back to the default one, there is no visual indication that the change was successful. Neither the template name in the sidebar or the layout actually changes.
Why?
As @talldan mentions here, internally we were using
__experimentalGetTemplateForLinkwhich doesn't take into account unsaved changes(in our case thetemplateprop) which results in the wrong template resolution. The same problem was encountered in switching templates in site editor and has been resolved with this PR, that introduced thegetDefaultTemplateIdselector I'm using here.Testing Instructions
Screenshots or screencast
Screen.Recording.2024-01-10.at.2.25.00.PM.mov