Skip to content

Regression: Post Title block doesn't support paragraph; level:"0" results in <h0> elements #53594

Closed

Description

@mrwweb

Description

Previously, the Post Title block offered the option to display the post title in a paragraph tag. It appears that this was removed in 6.3 (also here) as part of the work to pull the HeadingLevelDropdown into its own component. Given that the component supports a paragraph tag when level: "0", I don't understand why this was removed.

I have a site using a Post Title block with level: "0". In 6.2, it outputs a paragraph. In 6.3, it creates an h0 element that results in some styling issues for us. Notably, the block doesn't appear to have any validation issues, I think because 0 is expected as a supported value of the level attribute (as it should be).

Given that this was previously supported and produces an invalid HTML element, this feels like a fairly urgent issue worth addressing in a point release.

Tagging the three people who worked on the relevant commit in hopes of gaining some context: @carolinan, @geriux, @Mamaduka

Step-by-step reproduction instructions

  1. Paste <!-- wp:post-title {"level":0} /--> into post editor
  2. View resulting post markup with <h0> elements around the Post Title

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 6.3
  • No Gutenberg plugin
  • Custom theme

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

Activity

  1. carolinan commented on Aug 12, 2023

    @carolinan
    Contributor

    Hi,
    It has been more than 6 months, so my memory is not super fresh, but through my testing when working on the block, what I found was that using the post title as a paragraph was never actually supported.
    https://github.com/WordPress/gutenberg/pull/46003/files#r1031159154
    Can you explain to me in detail how this was used? Did you perhaps add the paragraph "level" directly via the HTML in the markup, not via the interface?
    With the interface, I mean the drop-down with the levels in the block toolbar, the drop-down did not support paragraphs.

    I personally wanted this to be supported, but it was downvoted in discussions, for accessibility reasons:
    #30549

  2. added
    [Block] Post Title
    on Aug 12, 2023
  3. t-hamano commented on Aug 12, 2023

    @t-hamano
    Contributor

    I tested it with WordPress 6.2.2, and there are indeed no paragraph in the Post Title block dropdown, so I don't think it could be a paragraph block unless you intentionally set the level attribute to zero.

    6 2_heading_dropdown

    Also, I think it was easy to notice that this was not the intent, because if level:0 was specified, nothing would be rendered in the dropdown icon.

    6 2_paragraph

    In WordPress 6.3, it renders as h0, which outputs an error to the browser console.

    warning

    Therefore, I think it would be a good idea to add a process to migrate blocks with level:0 attributes to level:2, etc.

  4. jorgefilipecosta commented on Aug 15, 2023

    @jorgefilipecosta
    Member

    Therefore, I think it would be a good idea to add a process to migrate blocks with level:0 attributes to level:2, etc.

    Based on the discussion, the UI has never allowed the selection of level 0. So, I suppose it's not a migration that core needs to include for every site. It appears that websites depending on manually altering an attribute to level 0 in the code editor should implement this kind of migration that's specific to them. If that's the case, can we close the issue?

  5. added
    [Status] Needs More Info
    on Aug 15, 2023
  6. mrwweb commented on Aug 15, 2023

    @mrwweb
    Author

    It's been about ~9 months since the page in question was made, so I cannot fully remember either. If I did it manually, I'm almost positive that all I did was change level: "1" to level: "0" in the block's attribute comments. I could have also made a Block Pattern or created a Block Variation.

    I'm with @carolinan and others wishing this were supported, ironically for accessibility reasons so I can have a post template (on the home page) referencing the post title which is not the h1 on that template.

    Note: The site title block still supports the level: 0 logic.

    I suppose we could close this as a duplicate of #30549. What gives me pause is that it just feels weird that this was explicitly supported in the code for multiple versions of WordPress. I understand there wasn't a UI for it, but does that mean that any undocumented attribute is considered experimental unless there's any explicit UI for it? Could the support for the 0 attribute be added back explicitly without a UI. That would at least address the accessibility concerns raised since it would require that you "know what you're doing" to get the paragraph output.

    Pardon me for all the thinking out loud here. I'll follow the consensus, but it would just be nice to understand the precedents.

  7. added
    [Type] Discussion
    [Type] Regression
    and removed
    [Type] Discussion
    on Aug 30, 2023
  8. github-actions commented on Sep 15, 2023

    @github-actions

    Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.

  9. added
    [Status] Stale
    on Sep 15, 2023
  10. jordesign commented on Oct 26, 2023

    @jordesign
    Contributor

    With no further discussion on this issue - and no additional reports, I will close it. If we receive more reports in the future we can open once again.

  11. mrwweb commented on Nov 8, 2023

    @mrwweb
    Author

    @jordesign The other day I ran into a very real use-case for this feature. I'd love to hide the Latest Post block on my sites and instead use the Query Block as a replacement. However, since the Post Title must always be a heading, it's actually impossible to use it as a like-for-like replacement if I want to make a stripped down list of posts, e.g.:

    <ul>
        <li><a href="">{Post Title}</a></li>
        <li><a href="">{Post Title}</a></li>
        <li><a href="">{Post Title}</a></li>
    </ul>

    It's possible that a "Level 0" isn't exactly the right solution for this use-case, but it definitely once-again raises the need for an option to use the Post Title block without the heading markup.

  12. mrwweb commented on Nov 10, 2023

    @mrwweb
    Author

    @jordesign Still hoping to get this re-opened.

    As another point in favor of supporting a non-heading markup option, @afercia just pointed out on #50402 that the Site Title block does still offer a Paragraph option in the heading selector.

  13. self-assigned this
    on Apr 7, 2024
  14. added
    [Status] In Progress
    on Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Block] Post Title[Status] In Progress[Status] Needs More Info[Status] Stale[Type] Regression

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions