From 81158e2c703cd45484be017f4a591aa2c3dfdaff Mon Sep 17 00:00:00 2001 From: Jere Ljungberg Date: Tue, 25 Apr 2023 13:56:18 +0300 Subject: [PATCH 1/3] UHF-7853: Enhance accessibility in announcement component - Wrap announcement in
- Add preprocess function to generate type-specific aria-labels --- hdbt.theme | 18 ++++++++++++++++++ .../node--announcement--default.html.twig | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hdbt.theme b/hdbt.theme index 37214518f..d84516175 100644 --- a/hdbt.theme +++ b/hdbt.theme @@ -1547,3 +1547,21 @@ function hdbt_preprocess_paragraph__school_search(array &$variables): void { $variables['#attached']['drupalSettings']['helfi_school_search']['cookie_privacy_url'] = $privacyUrl->toString(); } } + +/** + * Implements hook_preprocess_HOOK(). + */ +function hdbt_preprocess_node__announcement(array &$variables) { + $type = $variables['node']->get('field_announcement_type')->value; + + $type_label = match($type) { + 'alert' => t('Alert'), + 'attention' => t('Attention'), + default => t('Notification') + }; + + $close_label = t('Close'); + + $variables['type_label'] = $type_label; + $variables['close_label'] = $close_label; +} diff --git a/templates/content/node--announcement--default.html.twig b/templates/content/node--announcement--default.html.twig index 926aae536..66d3e9ee8 100644 --- a/templates/content/node--announcement--default.html.twig +++ b/templates/content/node--announcement--default.html.twig @@ -8,7 +8,7 @@ {% set link = content.field_announcement_link[0] %} -
+
{% if content.body|render != null %} @@ -23,7 +23,7 @@ {% endif %}
-
+
\ No newline at end of file From 5f7e2737f9a3684d46839f9a6dcb51745fefcba0 Mon Sep 17 00:00:00 2001 From: Jere Ljungberg Date: Tue, 25 Apr 2023 13:57:50 +0300 Subject: [PATCH 2/3] UHF-7853: Remove misleading aria-labelleby and role tags from status messages --- templates/misc/status-messages.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/misc/status-messages.html.twig b/templates/misc/status-messages.html.twig index 57906b8d8..7e32e5fb9 100644 --- a/templates/misc/status-messages.html.twig +++ b/templates/misc/status-messages.html.twig @@ -50,7 +50,7 @@
{% set is_message_with_title = status_headings[type] %} {% set is_message_with_icon = type in ['error', 'default', 'warning', 'success'] %} -