Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295330

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

$
0
0

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.


Viewing all articles
Browse latest Browse all 295330

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>