The drupal/section block should use configurable element

Created on 20 January 2022, over 3 years ago
Updated 15 November 2023, over 1 year ago

Problem/Motivation

When using the drupal/section block provided by this module the resulting output contains the <main></main> HTML element. There should only ever be one of these as it is a landmark role in ARIA and at the same level as other landmarks. This would usually be controlled in a Twig template handling the layout of the page.

Steps to reproduce

Add a Gutenberg template for the basic page containing:

[
  ["drupal/section", {"placeholder": "Insert content"}]
]

Then create a node and add content to the templated area.
View the source of the node output and note that the content is wrapped in a <main> tag.

Proposed resolution

Instead of using <main> I propose the tag is configurable. So the template could contain:

[
  ["drupal/section", {"placeholder": "Insert content", "tag": "section"}]
]

Which would output a <section> instead of a <main> tag.

If no tag is provided it should fall back to a <div> tag which has no semantic meaning and is the most generic and therefore safe container.

Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

🇮🇹Italy tanc Italy

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇴Norway eiriksm Norway

    I think we would need the following tests for this:

    • A test checking that installing gutenberg and applying default attributes using the mentioned template ends up using main
    • A test checking that we can add a custom tag there, and creating a node end up using that tag
    • A test checking that even if we have content from before, and then changing things so we get that new tag, we would keep the existing main tag on the old content, and get the new tag on the new content
  • 🇳🇴Norway vegardjo

    Hey, I've suggested an alternative route for this here 📌 The drupal/section block should not use Active

Production build 0.71.5 2024