-
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
useEditorTitle: fix wrong request without ID #67475
Conversation
@@ -22,6 +22,10 @@ function useEditorTitle( postType, postId ) { | |||
const { getEditedEntityRecord, hasFinishedResolution } = | |||
select( coreStore ); | |||
|
|||
if ( ! postId ) { |
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 think for the home page of the site editor, there's no postId (and other pages). Won't this have an impact there?
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.
You mean the site editor root? Yes, there's an ID it seems, it's the template ID. Which other pages would have no ID? useEditorTitle
seems to always be called either the post/page ID or the template ID.
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 think when you are on data view pages, the title does not update, but that's the case in trunk too?
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.
Btw, it's currently not erroring because getEditedEntityRecord
returns false
if it's not loaded yet, which getTemplateInfo
is destructuring.
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 think you're right.
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: +10 B (0%) Total Size: 1.83 MB
ℹ️ View Unchanged
|
Flaky tests detected in f8ccd8d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12120826554
|
Co-authored-by: ellatrix <[email protected]> Co-authored-by: youknowriad <[email protected]>
Co-authored-by: ellatrix <[email protected]> Co-authored-by: youknowriad <[email protected]>
What?
I think this has been introduced in #66955.
postId
may be undefined (try the root page in the Site Editor), which is causing a request to/templates
(without the ID, so a useless request). This is delaying editor load (though we are not currently measuring it for template editing).Why?
How?
Return early.
Testing Instructions
Open the Site Editor root, and check the first few
fetch
requests. Notice the loader before this PR, after this PR it's only 100ms, so it doesn't really show up.I've added a test so we don't make these regressions again.
Testing Instructions for Keyboard
Screenshots or screencast