summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2014-05-13 11:42:10 (GMT)
committerNathaniel Catchpole2014-05-13 11:42:10 (GMT)
commit14baa0b3850f164cc1bd98101ca38840fad92edd (patch)
tree1d2f89ee36c47c1a3ff2a69d026992a9691fb2db
parent7a8d0cd2b7e69259b65e48d8572c4042122c70c4 (diff)
Issue #2126761 by Tim Bozeman, SGhosh, Jalandhar: The body field summary textarea indicates it has a description with aria-describedby attribute, but the DOM id value points to a non-existent node.
-rw-r--r--core/modules/filter/filter.module25
-rw-r--r--core/modules/filter/templates/text-format-wrapper.html.twig5
2 files changed, 28 insertions, 2 deletions
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index cb17c44..3efe9ad 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -63,7 +63,11 @@ function filter_theme() {
'template' => 'filter-tips',
),
'text_format_wrapper' => array(
- 'variables' => array('children' => NULL, 'description' => NULL),
+ 'variables' => array(
+ 'children' => NULL,
+ 'description' => NULL,
+ 'attributes' => array(),
+ ),
'template' => 'text-format-wrapper',
),
'filter_guidelines' => array(
@@ -665,6 +669,25 @@ function template_preprocess_filter_guidelines(&$variables) {
}
/**
+ * Prepares variables for text format wrapper templates.
+ *
+ * Default template: text-format-wrapper.html.twig.
+ *
+ * @param array $variables
+ * An associative array containing:
+ * - attributes: An associative array containing properties of the element.
+ */
+function template_preprocess_text_format_wrapper(&$variables) {
+ // Add element class and id for screen readers.
+ if (isset($variables['attributes']['aria-describedby'])) {
+ $variables['attributes']['class'][] = 'description';
+ $variables['attributes']['id'] = $variables['attributes']['aria-describedby'];
+ // Remove aria-describedby attribute as it shouldn't be visible here.
+ unset($variables['attributes']['aria-describedby']);
+ }
+}
+
+/**
* Prepares variables for filter tips templates.
*
* Default template: filter-tips.html.twig.
diff --git a/core/modules/filter/templates/text-format-wrapper.html.twig b/core/modules/filter/templates/text-format-wrapper.html.twig
index f453971..b4ff1cc 100644
--- a/core/modules/filter/templates/text-format-wrapper.html.twig
+++ b/core/modules/filter/templates/text-format-wrapper.html.twig
@@ -6,6 +6,9 @@
* Available variables:
* - children: Text format element children.
* - description: Text format element description.
+ * - attributes: HTML attributes for the containing element.
+ *
+ * @see template_preprocess_text_format_wrapper()
*
* @ingroup themeable
*/
@@ -13,6 +16,6 @@
<div class="text-format-wrapper form-item">
{{ children }}
{% if description %}
- <div class="description">{{ description }}</div>
+ <div{{ attributes }}>{{ description }}</div>
{% endif %}
</div>