Skip to content

Commit

Permalink
VACMS-10113: Changed label to span using a patch. (#19796)
Browse files Browse the repository at this point in the history
* VACMS-10113: Changed label to span using a patch.

* VACMS-10113: Fix patch name error.

* VACMS-10113: Style changes to layout.

* VACMS-10113: Updating composer.lcok.

---------

Co-authored-by: JakeBapple <[email protected]>
  • Loading branch information
anantais and JakeBapple authored Nov 12, 2024
1 parent 2547fde commit 61f789f
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@
"3241295 - CKEditor 5 isn't respecting field widgets row settings": "patches/3241295-ckeditor-5-not-respecting-field-widgets-row-settings.patch",
"3376267 - [upstream] Add style to anchor leads to unusable behavior": "patches/3376267-add-style-to-anchor-leads-to-unusable-behavior.patch",
"3285657 - The content has either been modified by another user, or you have already submitted modifications error": "patches/3285657-node-lock-translations.patch",
"VACMS-19177 remove username form logging in user module": "patches/VACMS-19177-patch-for-user-module-to-log-uid.patch"
"VACMS-19177 remove username form logging in user module": "patches/VACMS-19177-patch-for-user-module-to-log-uid.patch",
"3082011 - Fix for orphaned label tags": "patches/3082011-19-do-not-use-label-HTML-tag-in-item-form-element.patch"
},
"drupal/danse": {
"3364925 - added explicit access check": "patches/3364925-added-explicit-access-check.patch"
Expand Down
2 changes: 1 addition & 1 deletion composer.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "968afd2e6b74d4dd070d3e1695fe3c31",
"content-hash": "ee62fce148618949bab1fc8e4a438044",
"packages": [
{
"name": "asm89/stack-cors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,16 @@
grid-area: 2 / 1 / 2 / 2;
}
}

// Fix to align elements in Editorial Workflow current state on all pages
.js-form-item-moderation-state-0-current {
span {
display: inline;

&:first-child {
&::after {
content: ":";
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 4f353d0..950f185 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -497,6 +497,7 @@ function template_preprocess_form_element(&$variables) {
$variables['label'] = ['#theme' => 'form_element_label'];
$variables['label'] += array_intersect_key($element, array_flip(['#id', '#required', '#title', '#title_display']));
$variables['label']['#attributes'] = $element['#label_attributes'];
+ $variables['label']['#tag'] = $element['#title_tag'] ?? ($element['#type'] === 'item' ? 'span' : 'label');
if (!empty($element['#label_for'])) {
$variables['label']['#for'] = $element['#label_for'];
if (!empty($element['#id'])) {
@@ -541,18 +542,22 @@ function template_preprocess_form_element_label(&$variables) {
// Pass elements title_display to template.
$variables['title_display'] = $element['#title_display'];

- // A #for property of a dedicated #type 'label' element as precedence.
- if (!empty($element['#for'])) {
- $variables['attributes']['for'] = $element['#for'];
- // A custom #id allows the referenced form input element to refer back to
- // the label element; e.g., in the 'aria-labelledby' attribute.
- if (!empty($element['#id'])) {
- $variables['attributes']['id'] = $element['#id'];
+ $variables['tag'] = $element['#tag'];
+
+ if ($variables['tag'] === 'label') {
+ // A #for property of a dedicated #type 'label' element as precedence.
+ if (!empty($element['#for'])) {
+ $variables['attributes']['for'] = $element['#for'];
+ // A custom #id allows the referenced form input element to refer back to
+ // the label element; e.g., in the 'aria-labelledby' attribute.
+ if (!empty($element['#id'])) {
+ $variables['attributes']['id'] = $element['#id'];
+ }
+ }
+ // Otherwise, point to the #id of the form input element.
+ elseif (!empty($element['#id'])) {
+ $variables['attributes']['for'] = $element['#id'];
}
- }
- // Otherwise, point to the #id of the form input element.
- elseif (!empty($element['#id'])) {
- $variables['attributes']['for'] = $element['#id'];
}

// Pass elements required to template.
diff --git a/core/modules/system/templates/form-element-label.html.twig b/core/modules/system/templates/form-element-label.html.twig
index 7696609..90dd02b 100644
--- a/core/modules/system/templates/form-element-label.html.twig
+++ b/core/modules/system/templates/form-element-label.html.twig
@@ -23,5 +23,5 @@
]
%}
{% if title is not empty or required -%}
- <label{{ attributes.addClass(classes) }}>{{ title }}</label>
+ <{{ tag }}{{ attributes.addClass(classes) }}>{{ title }}</{{ tag }}>
{%- endif %}
diff --git a/core/themes/claro/templates/form-element-label.html.twig b/core/themes/claro/templates/form-element-label.html.twig
index d0ec8a3..2424e5f 100644
--- a/core/themes/claro/templates/form-element-label.html.twig
+++ b/core/themes/claro/templates/form-element-label.html.twig
@@ -22,5 +22,5 @@
]
%}
{% if title is not empty or required -%}
- <label{{ attributes.addClass(classes) }}>{{ title }}</label>
+ <{{ tag }}{{ attributes.addClass(classes) }}>{{ title }}</{{ tag }}>
{%- endif %}
diff --git a/core/themes/stable9/templates/form/form-element-label.html.twig b/core/themes/stable9/templates/form/form-element-label.html.twig
index 7c2f8f2..3d51b32 100644
--- a/core/themes/stable9/templates/form/form-element-label.html.twig
+++ b/core/themes/stable9/templates/form/form-element-label.html.twig
@@ -21,5 +21,5 @@
]
%}
{% if title is not empty or required -%}
- <label{{ attributes.addClass(classes) }}>{{ title }}</label>
+ <{{ tag }}{{ attributes.addClass(classes) }}>{{ title }}</{{ tag }}>
{%- endif %}
diff --git a/core/themes/starterkit_theme/templates/form/form-element-label.html.twig b/core/themes/starterkit_theme/templates/form/form-element-label.html.twig
index 7c2f8f2..3d51b32 100644
--- a/core/themes/starterkit_theme/templates/form/form-element-label.html.twig
+++ b/core/themes/starterkit_theme/templates/form/form-element-label.html.twig
@@ -21,5 +21,5 @@
]
%}
{% if title is not empty or required -%}
- <label{{ attributes.addClass(classes) }}>{{ title }}</label>
+ <{{ tag }}{{ attributes.addClass(classes) }}>{{ title }}</{{ tag }}>
{%- endif %}

0 comments on commit 61f789f

Please sign in to comment.