-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Table of contents block – links don't work on initial page save #43595
Comments
I was able to reproduce this issue following the steps. The tricky part is that the public URL is generated after the publish action. When a page is added, the links of the headings are set correctly to the block's store without refreshing the edit page, but the page requires to be updated to use the public URL inside its content. As a solution, we can remove the page URL from the links and keep only the generated hashtags. For example, from I'm unable to find information on whether there was a reason for using the full URLs. Such page links work with hashtags only, and this solution might be sufficient. |
Following the replication steps outlined in this issue, the ToC links worked for me on initial save. @Greatdane Could you confirm if this issue has been resolved or expand on the test steps? Screen.Recording.2022-08-30.at.2.47.08.pm.mp4 |
@aaronrobertshaw, which permalink structure did you use while recording the video? If the Plain permalink structure is used, the block works. However, it doesn't work for me when using other permalink structures such as Post Name. In that case, the links don't include the page's name, but |
Hi @aatanasovdev, I tested with both Plain and Post Name permalink structures however I only posted a single video. Here's a video of the table of contents working for me on initial save with the Post Name permalink setting selected. Screen.Recording.2022-09-05.at.7.56.07.pm.mp4 |
Hi @aaronrobertshaw, it looks like you're adding the Table of Content block to a post, not a page. Publishing a post works slightly differently than a page. When we add a post, there is no auto-draft URL generation before publishing the page (I haven't checked why this happens, but it has to be consistent). In that case, the TOC block uses URLs like On the other side, when a page is published, the TOC block uses Here is a video that shows how the block behaves. Test-TOC-block.webmProbably, it will be better if the Alternatively, the links can be regenerated automatically behind the scenes when a page is published. However, it doesn't seem right. |
I can confirm incorrect behaviour:
WordPress version |
I could reproduce this as well. Using Gutenberg 16.4. This is the code on the page in case it helps: https://d.pr/n/kp52JN |
Noting that this was brought up in the twenty fifth call for testing for the FSE Outreach Program using 16.4:
I've added it to the stabilizing the TOC issue! |
Description
If you add the Table of Contents block to a new page, when you publish the page, the links don't work properly and instead open a new page with a Page not found error. The URL is retaining an auto-draft in it. If you edit and Update the page, the links will then work properly. Alternatively, if you publish the page first, then add the Table of Contents block, they will work correctly.
Step-by-step reproduction instructions
Create a new page
Add content, with headings, and the Table of Content block
Publish the page
View the page
Try the TOC links
Return to the editor and make a change
Update the published page
View the page
The TOC links now work
Screenshots, screen recording, code snippet
Screen.Capture.on.2022-08-20.at.10-40-21.mp4
Environment info
WordPress version 6.0.1
Gutenberg 13.9.0
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: