Allow modules to classify blocks when defining them, so WAI-ARIA roles can automatically be added in the theme layer

Created on 12 January 2012, over 12 years ago
Updated 31 May 2023, over 1 year ago

Problem/Motivation

See #1183042-70: Regression: Add WAI-ARIA roles to Core blocks and the next few comments that follow it. (@todo: It would be good to summarize those points here.)

Proposed resolution

One of the following:

  1. Use hook_block_view(). This would rely on #1302482: Ensure render arrays properly handle #attributes and add them there instead of preprocess hooks and the modules would add the WAI-ARIA attributes directly.
  2. Classify blocks in hook_block_info(), so that the metadata is available in the correct place, and then have template_preprocess_block() add the WAI-ARIA attributes based on that. This would be straightforward also, except the hook_block_info() 'properties' element is currently not stored in the database so it's not available when a block is loaded. We might need to put it in the database for this to work. That's probably a good idea anyway, since currently almost everything in hook_block_info() lives in the database, and it's inconsistent that this one isn't.
  3. Do nothing, as per #1, since "We use preprocess functions to add attributes all over the place in core."

Remaining tasks

Original report by David_Rothstein

For background on this issue, read #1183042-70: Regression: Add WAI-ARIA roles to Core blocks and the next few comments that follow it.

Here, we should do one of the following:

  1. Use hook_block_view(). This would rely on #1302482: Ensure render arrays properly handle #attributes and add them there instead of preprocess hooks and the modules would add the WAI-ARIA attributes directly.
  2. Classify blocks in hook_block_info(), so that the metadata is available in the correct place, and then have template_preprocess_block() add the WAI-ARIA attributes based on that. This would be straightforward also, except the hook_block_info() 'properties' element is currently not stored in the database so it's not available when a block is loaded. We might need to put it in the database for this to work. That's probably a good idea anyway, since currently almost everything in hook_block_info() lives in the database, and it's inconsistent that this one isn't.

I prefer option #2, but either is preferable to the current situation where each module has to implement a theme preprocess function to add the role attribute to its blocks.

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Block 

Last updated 3 days ago

Created by

🇺🇸United States David_Rothstein

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

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

  • Accessibility

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

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.

Production build 0.71.5 2024