Messages should have role=status instead of role=contentinfo

Created on 6 February 2018, almost 7 years ago
Updated 16 January 2023, almost 2 years ago

Problem

Messages currently have a role="contentinfo" wrapper for status messages (compared with role="alert" for error messages).

contentinfo is inappropriate here, because it's supposed to be for information about the document as a whole, not status updates. It's a landmark role, and there should only be one such contentinfo region per page. It's intended to serve the same purpose as a top-level HTML footer element. Using contentinfo for messages may be present some confusion for users who navigate by landmark regions.

Proposed resolution

  1. Replace the role="contentinfo" from the message-type wrapper DIV with role="region" and change the aria-label to "System Messages".
  2. Leave the <div role="alert"> in place for the error message group.
  3. Add a <div role="status"> wrapper for Status and Warning message groups.

Here's a simplified before/after summary of this.

Structure BEFORE:

div role="contentinfo" aria-label="Status message"
    h2.visually-hidden
    ul

div role="contentinfo" aria-label="Error message"
    div role="alert"
        h2.visually-hidden
        ul

Structure AFTER:

div role="region" aria-label="System messages"
    
    div role="status" // Status & Warning messages
        h2.visually-hidden
        ul

    div role="alert"  // Error messages
        h2.visually-hidden
        ul
๐Ÿ› Bug report
Status

Needs work

Version

10.1 โœจ

Component
Markupย  โ†’

Last updated 2 days ago

No maintainer
Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom andrewmacpherson

Live updates comments and jobs are added and updated live.
  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States edmund.dunn Olympia, WA

    Rerolled for 10.1. Applies cleanly.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    Patch Failed to Apply
  • last update over 1 year ago
    Patch Failed to Apply
  • Tests might fail and they will require extra work

  • Status changed to Needs review about 1 year ago
  • last update about 1 year ago
    29,630 pass, 6 fail
  • last update about 1 year ago
    30,347 pass, 6 fail
  • ๐Ÿ‡ต๐Ÿ‡ชPeru marvil07

    Back to NR for the new patches.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Hardik_Patel_12 India

    Solving failed test cases and rerolling for 11.x

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Environment: PHP 8.1 & MariaDB 10.3.22
    last update 11 months ago
    25,976 pass, 1,827 fail
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Environment: PHP 8.1 & MySQL 5.7 updated deps
    last update 11 months ago
    Custom Commands Failed
  • last update 11 months ago
    25,965 pass, 1,833 fail
  • Status changed to Needs work 11 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Caused massive test failures.

    Was previously tagged for issue summary, has that been completed.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Hardik_Patel_12 India

    Rerolling to 11.x from #49.

  • last update 10 months ago
    25,976 pass, 1,827 fail
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    Prashant.c โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    Submitting Patch for 11.x and raising the MR as well.

    Thank you.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Environment: PHP 8.1 & MariaDB 10.3.22
    last update 10 months ago
    25,980 pass, 1,813 fail
  • Pipeline finished with Failed
    10 months ago
    Total: 528s
    #73278
  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Large number of failures.

    Also was previously tagged for issue summary update.

    @Prashant.c there's no interdiff added what did you do different from #55

  • last update 10 months ago
    Patch Failed to Apply
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bnjmnm Ann Arbor, MI

    I opened MR 6112 as patches don't seem to be testing properly. Most of the 1800+ test failures in #55 and #58 do not seem to have anything to do with the code changes. Among other things there are "missing composer.lock" messages, and that file is not touched in either patch. The MR I created is failing ~3 tests, so those will need to be addressed, but that should be straightforward compared to the unexpectedly huge fail count that suddenly appeared (and not at all the fault of @Prashant.c or @Hardik_Patel_12)

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Hardik_Patel_12 India

    @bnjmnm, I have observed similar challenges in several other issues. When using the patch method, it leads to significant unrelated failures for the composer and other components, similar to the problems described in issues #55 and #58. However, the Merge Request (MR) method is functioning properly.

  • Pipeline finished with Success
    10 months ago
    Total: 655s
    #75355
  • First commit to issue fork.
  • Pipeline finished with Failed
    10 months ago
    Total: 271s
    #86158
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States neclimdul Houston, TX
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bapplejax

    Submitting a re-roll of patch #58 to allow for a clean application to 10.3.x. Some syntax and line number changes.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bapplejax

    the 65-11.x.patch is a reroll to cleanly apply patch #58 to 10.3.x

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 2dareis2do

    The role="contentinfo" is wrong. This role is for a landmark region, equivalent to HTML , with the extra proviso that there can only be one contentinfo landmark per document, and it must be a top-level landmark. I'm not sure how we ended up with role="contentinfo", but perhaps the idea was to make the messages easy to find using landmark regions. I like that idea, and we can use

    instead, and it will count as a landmark region, as long as it has an ARIA label.

    Agreed that there should not be more than one contentinfo per page.

    Within any document or application, the author SHOULD mark no more than one element with the contentinfo role.

    https://www.w3.org/TR/wai-aria-1.2/#contentinfo

    How about just using complementary role. Status, Error or Notice is often (not always) related to the page you are on.

    https://www.w3.org/TR/wai-aria-1.2/#complementary

    also

    The complementary role indicates that contained content is relevant to the main content. If the complementary content is completely separable from the main content, it may be appropriate to use a more general role.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 2dareis2do

    Looking at Claro, I think the implementation is about right:

    Markup is like so:

    Looking at output from claro, I think that they have it about right. i.e. one message per notice.

    Markup is output in a single region.

    <div class="messages__wrapper">
    <div class="messages messages--status messages-list__item" role="status" aria-labelledby="status-104584368505794-title" data-drupal-message-id="status-104584368505794" data-drupal-message-type="status">
        <div class="messages__header">
          <h2 id="status-104584368505794-title" class="messages__title">
            Status message
          </h2>
        </div>
        <div class="messages__content">
          Antibot (system_clear_cache): disabled
        </div>
      </div><div class="messages messages--status messages-list__item" role="status" aria-labelledby="status-263254492006824-title" data-drupal-message-id="status-263254492006824" data-drupal-message-type="status">
        <div class="messages__header">
          <h2 id="status-263254492006824-title" class="messages__title">
            Status message
          </h2>
        </div>
        <div class="messages__content">
          Caches cleared.
        </div>
      </div><div class="messages messages--status messages-list__item" role="status" aria-labelledby="status-288152668342968-title" data-drupal-message-id="status-288152668342968" data-drupal-message-type="status">
        <div class="messages__header">
          <h2 id="status-288152668342968-title" class="messages__title">
            Status message
          </h2>
        </div>
        <div class="messages__content">
          Antibot (system_performance_settings): disabled
        </div>
      </div>
    </div>

    In theory I see no issue in giving messages__wrapper the role contentinfo

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 2dareis2do

    One challenge here is css frameworks like bootstrap use a single role for all types of notifications. i.e. role=

    here is an example for warning.

    <div class="alert alert-warning alert-dismissible fade show" role="alert">
      <strong>Holy guacamole!</strong> You should check in on some of those fields below.
      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
      </button>
    </div>
    

    To colour can also be changed. Here are some examples.

    <div class="alert alert-primary" role="alert">
      A simple primary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
    </div>
    <div class="alert alert-secondary" role="alert">
      A simple secondary alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
    </div>
    <div class="alert alert-success" role="alert">
      A simple success alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
    </div>
    <div class="alert alert-danger" role="alert">
      A simple danger alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
    </div>
    <div class="alert alert-warning" role="alert">
      A simple warning alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
    </div>
    <div class="alert alert-info" role="alert">
      A simple info alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
    </div>
    <div class="alert alert-light" role="alert">
      A simple light alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
    </div>
    <div class="alert alert-dark" role="alert">
      A simple dark alert with <a href="#" class="alert-link">an example link</a>. Give it a click if you like.
    </div>

    Certainly in Drupal, I would like to see the alerts expanded beyond the standard status, warning and error. This would be useful for theming.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 2dareis2do

    Updated example of Olivero.

    So it appears that notifications are grouped together for Olivero theme. This is different from Claro that has separate notifications.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 2dareis2do
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 2dareis2do
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 2dareis2do

    Ok so it turns out message are displayed differently depending if big pipe is enabled.

    If Big pipe is enabled messages are output in a group

    If Big Pipe is disabled, messages are output separately.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 2dareis2do

    With Big Pipe enabled if there is a single message (claro) outputs role=contentinfo

    With Big Pipe enabled
    If message is single than one output is role=contentinfo
    If output is more than one, output is role=status

    I think error messages may be treated slightly differently.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 2dareis2do
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 2dareis2do
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 2dareis2do

    Just wanted to share how out looks with big pipe enabled in Drupal 10.2.7 (it's quite rare to see all types on a single page - see attached)

    <div class="messages-list__wrapper">
                          
          <div role="contentinfo" aria-labelledby="message-error-title" class="messages-list__item messages messages--error">
                      <div role="alert">
                                  <div class="messages__header">
                                  <h2 id="message-error-title" class="messages__title">
                      Error message
                    </h2>
                              </div>
                        <div class="messages__content">
                              One or more problems were detected with your Drupal installation. Check the <a href="/admin/reports/status">status report</a> for more information.
                          </div>
                      </div>
                  </div>
                                      
          <div role="contentinfo" aria-labelledby="message-status-title" class="messages-list__item messages messages--status">
                                  <div class="messages__header">
                                  <h2 id="message-status-title" class="messages__title">
                      Status message
                    </h2>
                              </div>
                        <div class="messages__content">
                              Antibot (system_themes_admin_form): disabled
                          </div>
                  </div>
                                      
          <div role="contentinfo" aria-labelledby="message-warning-title" class="messages-list__item messages messages--warning">
                                  <div class="messages__header">
                                  <h2 id="message-warning-title" class="messages__title">
                      Warning message
                    </h2>
                              </div>
                        <div class="messages__content">
                              No update information available. <a href="/admin/reports/status/run-cron?destination=/admin/appearance&amp;token=QJoWTyS5Bcf8KP_gvhmjUwm-s1rlrvSqL3XHgVsxEKQ">Run cron</a> or <a href="/admin/reports/updates/check?destination=/admin/appearance&amp;token=CBZRlulFTH8gW_6DOzzFPvANhv3hgZZGZgPlEhP9noY">check manually</a>.
                          </div>
                  </div>
                      </div>

    AFAICT messages are also grouped by type even with big pipe disabled.

    Notice how there are multiple uses of role="contentinfo" on a single page which is obviously wrong.

    In 10.3 I believe behaviour has changed slightly depending on whether big pipe is enable or not.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bapplejax

    Rerolling patch #65 for Drupal 10.3.8. Line number updates and removal of edits to a template file where changes were addressed.

Production build 0.71.5 2024