Skip to content

Document structure and stats do not consistently process synced patterns (aka reusable blocks) #33079

Open

Description

@mrwweb

Preface: This behaves like a regression for the fix that closed #12042 and #11744.

Description

  • Headings in reusable blocks are not reflected in the Document Outline
  • The word count and character counts do not include blocks reusable blocks
  • The total block count, paragraph count, and heading count—surprisingly—are correct
  • The issue applies to saved and unsaved reusable blocks.
  • The issue happens regardless of whether the reusable block was created on the post or added to it from an existing reusable block.

Step-by-step reproduction instructions

  1. Make a new page
  2. Put some content on the page including multiple paragraphs and headings
  3. Note the Document Outline
  4. Turn at least one heading and paragraph of that content into a reusable block
  5. Note the change to the Document Outline

Expected behaviour

Document Outline reflects entire page content regardless of whether it includes a reusable block.

Actual behaviour

Document outline, word count, and character count exclude content in reusable blocks

Screenshots

Page content with four headings
List view of page showing two headings on page and two headings in a reusable block
Document Outline showing incorrect word, character, and outline. Showing correct heading and block count

WordPress information

  • WordPress version: 5.7.2
  • Gutenberg version: Not installed
  • Are all plugins except Gutenberg deactivated? No plugins at all
  • Are you using a default theme (e.g. Twenty Twenty-One)? Twenty Twenty

Device information

  • Device: Desktop
  • Operating system: Windows 10
  • Browser: Firefox 90.0b12

Activity

  1. added
    [Block] Block
    [Feature] Synced Patterns
    [Type] Bug
    General Interface
    on Jun 30, 2021
  2. added
    [Priority] Low
    [Feature] Document Outline
    on Aug 18, 2022
  3. kathrynwp commented on Aug 18, 2022

    @kathrynwp

    I can still replicate this with:

    WordPress 6.0.1
    No plugins active

    Initial Document Outline

    Add_New_Page_‹Self-hosted_Test—_WordPress

    Outline After One Heading & One Paragraph made into a Reusable Block

    Add_New_Page_‹Self-hosted_Test—_WordPress

  4. cbirdsong commented on Aug 21, 2023

    @cbirdsong

    I can confirm this is still an issue in Wordpress 6.3.

  5. jordesign commented on Oct 30, 2023

    @jordesign
    Contributor

    Confirming this is still true testing WP6.4 RC2 as well - headings and text within Synced patterns are not registered in the outline.

  6. removed
    [Priority] Low
    on Feb 20, 2024
  7. afercia commented on Feb 20, 2024

    @afercia
    Contributor

    This was also reported in #51909, for the sunced patterns.

    The word and characters count is still incorrect on current trunk version 17.7.0. See screenshot below.

    Removing the Low priority label as I think this should be fixed soon. Introducing features that break other existing features and keeping showing users very evident wrong inforation in the user interface is less than ideal. I'm not sure providing users with broken functionality helps with increasing trust with the editor.

    Screenshot 2024-02-20 at 09 22 36

  8. afercia commented on Feb 20, 2024

    @afercia
    Contributor

    After some quick testing, seems that on current trunk headings within synced patterns are now correctly parsed and added in the document outline. See animated GIF below, where after page refresh the synced pattern is fetched and when loaded the additional heading within the pattern is added to the document outline.

    Some more extended testing would be welcome.

    synced pattern outline

  9. changed the title [-]Document structure does not consistently process reusable blocks[/-] [+]Document structure and stats do not consistently process synced patterns (aka reusable blocks)[/+] on Feb 20, 2024
  10. afercia commented on Jun 19, 2024

    @afercia
    Contributor

    Update: testing on latest trunk 18.6.0-rc.1 this appears to still (again?) be a problem. Headings within Synced Patterens aren't included in the document outline. Which makes this feature visibly not fully functional and it's in this state since a while. I would appreciate this issue to get some more priority as it's a buggy functionality visible to all users.

    In the GIF below:

    • Keep the Document Overview > Outline panel open.
    • Add a couple headings and a paragraph.
    • Select the last heading and paragraph.
    • Make them a Synced pattern.
    • Observe the last heading disappears from the document outline.

    headings within patterns

  11. mrwweb commented on Jun 19, 2024

    @mrwweb
    Author

    Which makes this feature visibly not fully functional

    💯 This feels like a serious bug and one that hasn't been addressed for years now. It should ideally be addressed holistically to resolve both this issue and #5037 at the same time.

    It seems like the Document Outline needs to reflect the actual post content so the heading outline includes synced patterns as well as headings in custom blocks. Without that, the heading outline is frequently wrong, potentially providing an accessibility false positive in the outline.

  12. afercia commented on Jun 20, 2024

    @afercia
    Contributor

    It seems like the Document Outline needs to reflect the actual post content so the heading outline includes synced patterns as well as headings in custom blocks.

    I'd totally agree this feature needs to be rethinked. I'm not sure it can be based on the block type. To provide a fully correct outline, this feature needs to be aware of all the headings that are actually rendered, even if they come from, for example, shortcodes (besids patterns, custom blocks, stc.).

  13. afercia commented on Nov 12, 2024

    @afercia
    Contributor

    Looking back into this issue after conversation with @artemiomorales at Roma Core Days 2024. I can still reproduce this problem and it's even a broader issue now as the document outline doesn't sync after other updates of the content for example when binding a heading content to a source.

    Maybe the only way to reliably solve the overall issue would be soething like an action components can subscribe to that signals 'content has been updated'. When the editor signals a content update, other components, also the ones provided by plugins, may do their things.

    A few cases that can be reproduced on current trunk:

    1
    Synced patterns

    • Make a synced pattern with a group that contains a heading and a paragraph.
    • Create a post with some headings and paragraphs.
    • Open the Document Outline and observe it correctly shows the headings hierarchy.
    • Add the patterh to the post.
    • Observe the Document Outline doesn't update and does not show the heading contained in the pattern.

    Screenshot:

    Image

    To my understanding, a synced pattern in the post markup is only a reference e.g. <!-- wp:block {"ref":14285} /--> so there's actually no content in the post content that the editor itself or plugins can fetch. This appears to be an architectural problem because there are many cases where the editor itself or plugins would need to get the actual content.

    2
    Bound headings (and more in general any bound block) via the Bindings API.

    • Select one of the headings in your post.
    • Observe the Document Outline shows the heading and its content.
    • Bind the heading content to a post meta you previously registered. The post meta should provide a text string.
    • Observe the content of the heading updates in the editor canvas.
    • Observe the content of the heading does not update in the Document Outline.
    • Override the default value provided by post meta by editing the bound heading content.
    • Observe the Document Outline does not update the content of the heading.

    Screenshot:

    Image

    To my understanding, the post content still contains the original content so that the editor itself and plugins may not be aware the actual rendered content has updated. In the example below, the block markup still has the original heading content First heading while the actual rendered content comes from the bound post meta.

    <!-- wp:heading {"metadata":{"bindings":{"content":{"source":"core/post-meta","args":{"key":"text_short"}}}}} -->
    <h2 class="wp-block-heading">First heading</h2>
    <!-- /wp:heading -->
    

    This appears to be a broader issue and applies to other block attributes as well e.g. the alt text of an image, the content of buttons and any other block attribute value the editor itself or plugins may want to use in other components.

    3
    Plugins that need to get the actually rendered content after any update to run their things, e.g. Yoast SEO or other plugins.
    Cc @enricobattocchi

    Considering the two cases above and other potential cases in the future, the post content may not contain the actual content any longer. It may only contain references to other posts or references to sources.

    However, some functionalities of the editor itseld and plugisn may need to fetch the actual content, and may need to fetch it 'live' after any update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    General Interface[Block] Block[Feature] Document Outline[Feature] Synced Patterns[Type] Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions