diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 172d8e3..a5df6cd 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2402,16 +2402,6 @@ function template_preprocess_field(&$variables, $hook) { $variables['field_name'] = $element['#field_name']; $variables['field_type'] = $element['#field_type']; $variables['label_display'] = $element['#label_display']; - // Add a "clearfix" class to the wrapper since we float the label and the - // field items in field.module.css if the label is inline. - if ($element['#label_display'] == 'inline') { - $variables['attributes']['class'][] = 'clearfix'; - } - - // Hide labels visually, but display them to screenreaders if applicable. - if ($element['#label_display'] == 'visually_hidden') { - $variables['title_attributes']['class'][] = 'visually-hidden'; - } static $default_attributes; if (!isset($default_attributes)) { diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 54bfefa..65fbefd 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -857,17 +857,12 @@ function comment_preprocess_field(&$variables) { $variables['comment_display_mode'] = $element[0]['#comment_display_mode']; $variables['comment_type'] = $element[0]['#comment_type']; - // Adjust a comment field's attributes. - $variables['attributes']['class'][] = 'comment-wrapper'; - $variables['title_attributes']['class'][] = 'title'; - // Append additional attributes (eg. RDFa) from the first field item. $variables['attributes'] += $variables['item_attributes'][0]->storage(); // Create separate variables for the comments and comment form. $variables['comments'] = $element[0]['comments']; $variables['comment_form'] = $element[0]['comment_form']; - $variables['content_attributes']['class'] = array('title', 'comment-form__title'); } } diff --git a/core/modules/comment/templates/field--comment.html.twig b/core/modules/comment/templates/field--comment.html.twig index b074e45..67dcefb 100644 --- a/core/modules/comment/templates/field--comment.html.twig +++ b/core/modules/comment/templates/field--comment.html.twig @@ -28,21 +28,21 @@ 'field-' ~ entity_type|clean_class ~ '--' ~ field_name|clean_class, 'field-name-' ~ field_name|clean_class, 'field-type-' ~ field_type|clean_class, - 'field-label-' ~ label_display, + 'field-label-' ~ label_display|clean_class, 'comment-wrapper' ] %} {% if comments and not label_hidden %} {{ title_prefix }} - {{ label }} + {{ label }} {{ title_suffix }} {% endif %} {{ comments }} {% if comment_form %} - {{ 'Add new comment'|t }} + {{ 'Add new comment'|t }} {{ comment_form }} {% endif %} diff --git a/core/modules/node/templates/field--node--title.html.twig b/core/modules/node/templates/field--node--title.html.twig index dc8cbbd..cce56d5 100644 --- a/core/modules/node/templates/field--node--title.html.twig +++ b/core/modules/node/templates/field--node--title.html.twig @@ -21,7 +21,7 @@ 'field-' ~ entity_type|clean_class ~ '--' ~ field_name|clean_class, 'field-name-' ~ field_name|clean_class, 'field-type-' ~ field_type|clean_class, - 'field-label-' ~ label_display + 'field-label-' ~ label_display|clean_class ] %} {{ items }} diff --git a/core/modules/system/templates/field.html.twig b/core/modules/system/templates/field.html.twig index 229e64e..eb5e2d2 100644 --- a/core/modules/system/templates/field.html.twig +++ b/core/modules/system/templates/field.html.twig @@ -39,12 +39,19 @@ 'field-' ~ entity_type|clean_class ~ '--' ~ field_name|clean_class, 'field-name-' ~ field_name|clean_class, 'field-type-' ~ field_type|clean_class, - 'field-label-' ~ label_display + 'field-label-' ~ label_display|clean_class, + label_display == 'inline' ? 'clearfix' + ] +%} +{% + set title_classes = [ + 'field-label', + label_display == 'visually_hidden' ? 'visually-hidden' ] %} {% if not label_hidden %} - {{ label }}:  + {{ label }}:  {% endif %} {% for delta, item in items %} diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme index 27f8973..38fee74 100644 --- a/core/themes/bartik/bartik.theme +++ b/core/themes/bartik/bartik.theme @@ -151,21 +151,6 @@ function bartik_menu_tree__shortcut_default($variables) { } /** - * Implements hook_preprocess_HOOK() for field.html.twig. - * - * @see template_preprocess_field() - */ -function bartik_preprocess_field(&$variables) { - $element = $variables['element']; - if ($element['#field_type'] == 'taxonomy_term_reference') { - $variables['title_attributes']['class'][] = 'field-label'; - if ($variables['element']['#label_display'] == 'inline') { - $variables['title_attributes']['class'][] = 'inline'; - } - } -} - -/** * Helper function for handling the site name and slogan. */ function _bartik_process_page(&$variables) { diff --git a/core/themes/bartik/templates/field--taxonomy-term-reference.html.twig b/core/themes/bartik/templates/field--taxonomy-term-reference.html.twig index a28f175..2bbbd57 100644 --- a/core/themes/bartik/templates/field--taxonomy-term-reference.html.twig +++ b/core/themes/bartik/templates/field--taxonomy-term-reference.html.twig @@ -22,13 +22,20 @@ 'field-' ~ entity_type|clean_class ~ '--' ~ field_name|clean_class, 'field-name-' ~ field_name|clean_class, 'field-type-' ~ field_type|clean_class, - 'field-label-' ~ label_display, - 'clearfix' + 'field-label-' ~ label_display|clean_class, + label_display == 'inline' ? 'clearfix' + ] +%} +{% + set title_classes = [ + field_type == 'taxonomy_term_reference' ? 'field-label', + label_display == 'inline' ? 'inline', + label_display == 'visually_hidden' ? 'visually-hidden' ] %} {% if not label_hidden %} - {{ label }}: + {{ label }}: {% endif %} {% for delta, item in items %}