-
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
Document outline does not detect headings in the content when template-lock is used #68820
Comments
Hi @carolinan, I investigated the issue, and it seems to be related to the getBlocks function in Document Outline. While the post-content block has innerBlocks visible in the List View, it is returning an empty array in our case. This is why the Document Outline is unable to retrieve the heading blocks. I also tried fetching innerBlocks using getBlocksByClientId, but even then, the post-content block returns empty innerBlocks. |
Yes I found the same. |
Hi @carolinan for the solution, I was thinking of fetching the blocks from And for this additionally we need to fetch currentPostId and currentPostType from
|
I am not familiar with useEntityBlockEditor . There is another issue, and a decision needs to be made about what the expected workflow is. If the template has a heading, it is showing in the document outline even though it is not showing in the List View. |
Coming back to this, my assumption is that we do want the headings that are in the template to show in this case, because of course they affect the heading level order and duplicate H1 count on the page. |
Now, this will be a little tricky with the approach I mentioned, as Video shows Screen.Recording.2025-01-22.at.1.58.27.PM.mov |
I did not understand what you wanted to show with the video, since it does not show the outline. |
Is there a reason not to combine the blocks from the template (the current getblocks) and the post content? Why would only one be used? |
I suggest we agree on the source of the heading blocks the Document Outline should display before proceeding to the solution. |
I tested the post one more time and I was wrong. The pages and posts behave the same way. When the template shows they both show the headings that are in the template. So there is no bug with displaying the items. |
I think the document outline shows the correct headings, when "show template" is on it shows the headings of the template or else it will show the headings of the page content. Please correct me if I am wrong. document-outline-headings.mp4 |
That is how it is working today, yes. And my perspective is that it defeats the purpose of the outline.
|
Description
When you edit a post an enable the option "Show template", the document outline displays the heading levels correctly.
But when you create or edit a page, where the template is shown by default, the document outline incorrectly says that there are no headings in the content. Heading blocks in the template show.
This was reported in #68684 (comment) but I could not find a dedicated issue for it.
Please close this if it is a duplicate :)
Step-by-step reproduction instructions
With Gutenberg trunk active, create a new page.
In the content, add a heading.
Open the Document outline.
Confirm that it is empty.
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
The text was updated successfully, but these errors were encountered: