-
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 visibility of the template Welcome Guide in the Site Editor #64789
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +1.46 kB (+0.08%) Total Size: 1.78 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.
Thanks for the PR!
This is working as described for me. The Edit Template welcome guide now appears when I edit a page template in the site editor, and there's no flash from Page > Edit.
For other entities however I'm now seeing the "flash". For example,
- Open the site editor and edit the default template
- Create a pattern and then click "Edit original" to edit the pattern
- See our flashy friend appear
Kapture.2024-08-26.at.15.13.48.mp4
It doesn't happen when I create a template part in situ.
I'm not 100% on all the possible conditions, so it'd be good to get a second pair of eyes on it cc @noisysocks
Thanks for catching that! I’ve tinkered around more and have yet to find a set of conditions that work cleanly. I thought of a hackish solution that seems to work and pushed that 6a2bb80. I'd be keen to see if anyone can figure out a better way. |
Flaky tests detected in 29bfbc0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10691145052
|
I put this on the 6.7 board as the template welcome guide has had these issues since 6.6 it seems. |
const isVisible = | ||
postId !== priorPostId && | ||
isTemplateActive && | ||
! isEditorActive && |
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’ve removed the ! isEditorActive
condition because hasPreviousEntity
makes it redundant. The editor welcome guide can’t be visible when editing an entity that was arrived at through another entity.
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.
Thanks for persevering with this one!
Things are working well for me so far, and it's a definite improvement.
getCurrentPostType() === 'wp_template' | ||
); | ||
const edited = useEditedEntityRecord(); | ||
const isPostTypeTemplate = edited.record.type === 'wp_template'; |
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.
const isPostTypeTemplate = edited.record.type === 'wp_template'; | |
const isPostTypeTemplate = edited.record?.type === 'wp_template'; |
edited.record
can be false
on the first load.
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.
Aw, good catch. Yet in this case the optional chaining operator isn’t truly suited. Still, I’m not against trying to make this more explicit. I decided to leverage the isLoaded
property in the return value 29bfbc0. Once that becomes true
then record
won’t be false
.
Thanks for sticking it out with me Ramon! |
What?
Makes the Welcome guide for page templates actually show up when editing a page template.
Why?
To fix that the Welcome guide for a page template does not show up when expected as it was originally implemented in #52014. Also, to fix #62525, that describes how the Welcome guide flashes briefly at an unexpected moment.
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast