Skip to content
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 structure: Headings, Paragraphs, and Blocks counts are wrong #12042

Closed
afercia opened this issue Nov 18, 2018 · 6 comments
Closed

Document structure: Headings, Paragraphs, and Blocks counts are wrong #12042

afercia opened this issue Nov 18, 2018 · 6 comments
Labels
[Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Comments

@afercia
Copy link
Contributor

afercia commented Nov 18, 2018

Tested on latest master 4.4.0:

  • create a new post
  • enter a title
  • click in the default empty block
  • the "Content Structure" button gets enabled
  • click on the button to reveal the panel with the Headings, Paragraphs, and Blocks counts
  • I get the following counts:
    • 1 heading
    • 4 paragraphs
    • 8 blocks
  • also, the "Document Outline" title is visible, even if there's no headings hierarchy to show

4 4 0

Tried to save as draft, refresh the page, navigate away and edit the post again: the counts are always showing 4 paragraphs and 8 blocks which I don't have in my post.

I'm not sure when this started but I seem to recall it worked correctly at some point. I've randomly tried older versions of Gutenberg and in 2.9.0 the counts look correct:

2 9 0

@afercia afercia added [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release labels Nov 18, 2018
@earnjam
Copy link
Contributor

earnjam commented Nov 19, 2018

I haven't been able to recreate this yet 🤔

I initially tried in master, but I also tried with the v4.4.0 tag. I tried on WP 4.9.8 or WP 5.0 beta 5.

@afercia
Copy link
Contributor Author

afercia commented Nov 19, 2018

Will double check on a second machine because I've been noticing strange behaviors when trying to reproduce consistently.

@afercia
Copy link
Contributor Author

afercia commented Nov 19, 2018

Tested on a second machine

  • WP trunk also known as 5.1 alpha
  • Gutenberg 4.4.0 latest master

The counts are different but still wrong:

  • 0 headings
  • 5 paragraphs
  • 5 blocks

My test post has definitely just the title and the default empty block:

screenshot 145

No JS errors, just a few warnings related to deprecations.

@afercia
Copy link
Contributor Author

afercia commented Nov 19, 2018

After further investigation, it appears this has to do with reusable blocks. In the screenshot below, that's what state.editor.present.blocks.byClientId in getGlobalBlockCount() shows to me:

screenshot 2018-11-19 at 09 30 27

One of the empty blocks listed there is the default block in this post. All the other ones are reusable blocks not used in this post but returned and counted anyways.

I've also tried to delete all my reusable blocks and after that the count was correct. As soon as I've created a new reusable block in another post, then edited again this post, the count was 2.

This also explains why on the other machine I get a different count: it actually depends on the amount of reusable blocks saved in your database.

When testing, please make sure you have some reusable blocks.

@earnjam
Copy link
Contributor

earnjam commented Nov 19, 2018

Duplicate of #11744
This was fixed by #11787

@earnjam earnjam closed this as completed Nov 19, 2018
@afercia
Copy link
Contributor Author

afercia commented Nov 19, 2018

Ah I see. Merged 5 hours ago 🙂 👍 Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

No branches or pull requests

2 participants