Skip to content

Commit e284d57

Browse files
Merge pull request #1240 from City-of-Helsinki/bug/TP-2126_quick-link-target-blank
TP-2126 Added missing target=_blank for external quick links
2 parents c7ac144 + 78d36e4 commit e284d57

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

public/themes/custom/palvelumanuaali/palvelumanuaali.theme

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ function palvelumanuaali_preprocess_paragraph__quick_link__default(&$variables,
685685
if (!empty($content['field_short_description']['#items'])) {
686686
$description = $content['field_short_description']['#items']->getValue()[0]['value'];
687687
}
688+
$variables['quick_link']['external'] = $link['#url']->isExternal();
688689
$variables['quick_link']['attributes'] = [
689690
'title' => $title,
690691
'description' => $description,

public/themes/custom/palvelumanuaali/templates/paragraphs/paragraph--quick-link.html.twig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,19 @@
4242
paragraph.bundle|clean_class
4343
]
4444
%}
45-
{% if content['field_link'].0['#url'].external %}
45+
{% if quick_link.external %}
4646
{% set icon_name = 'arrow-right-2-ext' %}
4747
{% else %}
4848
{% set icon_name = 'arrow-right-2' %}
4949
{% endif %}
50-
5150
<a
5251
href="{{ quick_link.url }}"
5352
title="{{ quick_link.attributes.title }}"
5453
aria-label="{{ quick_link.attributes.title }}"
5554
aria-description="{{ quick_link.attributes.description }}"
55+
{% if quick_link.external %}
56+
target="_blank"
57+
{% endif %}
5658
class="quick-link add--break-word add--hyphen card--default-hover">
5759
{{ content|without('field_link') }}
5860
{% include "@atoms/images/icons/_icon.twig" with {

0 commit comments

Comments
 (0)