Post Title Block - fix "'length' of undefined" error.#30208
Conversation
|
Size Change: +13 B (0%) Total Size: 1.41 MB
ℹ️ View Unchanged
|
carolinan
left a comment
There was a problem hiding this comment.
I tested this PR together with 30203 and it is working well for me.
(I am curious why this error was present even if there were no published posts that were missing a title)
ntsekouras
left a comment
There was a problem hiding this comment.
I noticed this error yesterday when doing: #30203 and meant to see the root cause of this tomorrow.
This seems an interim fix and not the fix for the root problem, so I don't think we should land this. In my quick check I think it has to do with isLink handling in Post Title, but I'll look at it tomorrow if it's not resolved by then :)
|
I caused it so I will follow this closely 😬 |
There may be a larger root to address, but I also think it makes sense to not assume we have retrieved a proper post object in every possible circumstance. If we are going to show placeholder titles, we should do that when no proper post context is found as well. Whats happening here is There is not a problem once we are in the context of a post (placing this inside a page, post, or other query block), as it will pick up that context and show that title in the preview. Since the query block is our means of supplying a post context to these blocks, I think its fair to assume in placeholder flow/setup that no context may exist. |
Sort of, its only triggered when So it may be worthwhile to change the condition for the isLink version of the component from |
ntsekouras
left a comment
There was a problem hiding this comment.
Let's go with this for now and we can revisit especially with the changes in Query patterns that are being explored right now. Thanks!
Description
In some circumstances the post title block well receive
undefinedas the title value frompost:gutenberg/packages/block-library/src/post-title/edit.js
Line 59 in aad0052
Which results in an error when we try to access the
lengthproperty:gutenberg/packages/block-library/src/post-title/edit.js
Line 92 in aad0052
This can be reproduced consistently when we insert a Query block and its placeholder state is rendered:
(notice the block errors in the above previews).
Here, we define title to have a default value of the empty string so we are not using
undefinedfor input values and logic conditions expecting strings.How has this been tested?
After this change we should experience no console errors when inserting a query block, and the previews should show the proper placeholder of "No Title" instead of the block errors shown above:
Also verify the post title block continues to work as expected in other flows.
Screenshots
Types of changes
Checklist: