Support » Alpha/Beta/RC » Automated ID’s on headings causes duplicate ID, breaks validation

  • Hey!

    Testing WordPress 5.9 RC 3

    While the automatic id attributes on headings might be practical, it does cause an issue when validating documents with multiple identical headings. Like this:

    Vegetables (h1)
    Carrot (h2)
    Nutrition (h3)
    Potato (h2)
    Nutrition (h3)

    In this case, both “Nutrition” headings will automatically be assigned the same id #Nutrition, which breaks validation and isn’t best practice.

    https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id

    Has anyone got an idea on how to disable that feature in WordPress 5.9?

Viewing 7 replies - 1 through 7 (of 7 total)
  • In this case, both “Nutrition” headings will automatically be assigned the same id #Nutrition, which breaks validation and isn’t best practice.

    I just tried 5.9-RC3, and my experience was different: a dash and a number were always added to subsequent IDs when the texts were the same.

    So in your specific example, the IDs would be nutrition, nutrition-1, nutrition-2, etc.

    Thread Starter Bjarne Oldrup

    (@oldrup)

    Great feedback @gappiah – thank you 😊

    I see that heading ids are suffixed with -n when typed manually.

    But try and duplicate a heading or a group containing headings. Does the suffixing kick in? Not on my test site.

    Bjarne

    Testing this on WP 5.9 RC 4 now, will report back findings shortly…

    I can confirm that on WordPress 5.9 RC4 that copied blocks do not properly generate -n heading IDs and instead provide the same heading ID as its copied block.

    Sample Post content (the second Potato/Nutrition set of blocks were copied from the first set): https://cloudup.com/ckViRHnh43w
    Sample Post content source: https://cloudup.com/cEzGPspifAf

    Will now test with the latest version of Gutenberg to see if I can replicate there as well.

    This appears to be the related Gutenberg issue: https://github.com/WordPress/gutenberg/issues/36365

    I can confirm that this still exists with Gutenberg 12.4.1 activated as well.

    Moderator Marius L. J.

    (@clorith)

    Marking this topic as resolved, as there is a related ticket for follow-up, and further discussions about it should happen there so it is not lost.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.