Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mega-menu): Adding aria-describedby in info link - FRONT-4520 #3486

Merged
merged 12 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ exports[`Mega Menu Default renders correctly 1`] = `
>
<span
class="ecl-mega-menu__info-title"
id="about-the-news-id"
>
About the News and Media
</span>
Expand All @@ -166,6 +167,7 @@ exports[`Mega Menu Default renders correctly 1`] = `
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-news-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -575,6 +577,7 @@ exports[`Mega Menu Default renders correctly 1`] = `
>
<span
class="ecl-mega-menu__info-title"
id="about-the-ec-title-id"
>
About the European Commission
</span>
Expand All @@ -587,6 +590,7 @@ exports[`Mega Menu Default renders correctly 1`] = `
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-ec-title-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -708,6 +712,7 @@ exports[`Mega Menu Default renders correctly 1`] = `
>
<span
class="ecl-mega-menu__info-title"
id="about-key-priorities-id"
>
About key priorities
</span>
Expand Down Expand Up @@ -1173,6 +1178,7 @@ exports[`Mega Menu Default renders correctly with external items in the first le
>
<span
class="ecl-mega-menu__info-title"
id="about-the-news-id"
>
About the News and Media
</span>
Expand All @@ -1185,6 +1191,7 @@ exports[`Mega Menu Default renders correctly with external items in the first le
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-news-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -1594,6 +1601,7 @@ exports[`Mega Menu Default renders correctly with external items in the first le
>
<span
class="ecl-mega-menu__info-title"
id="about-the-ec-title-id"
>
About the European Commission
</span>
Expand All @@ -1606,6 +1614,7 @@ exports[`Mega Menu Default renders correctly with external items in the first le
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-ec-title-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -1727,6 +1736,7 @@ exports[`Mega Menu Default renders correctly with external items in the first le
>
<span
class="ecl-mega-menu__info-title"
id="about-key-priorities-id"
>
About key priorities
</span>
Expand Down Expand Up @@ -2194,6 +2204,7 @@ exports[`Mega Menu Default renders correctly with extra attributes 1`] = `
>
<span
class="ecl-mega-menu__info-title"
id="about-the-news-id"
>
About the News and Media
</span>
Expand All @@ -2206,6 +2217,7 @@ exports[`Mega Menu Default renders correctly with extra attributes 1`] = `
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-news-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -2615,6 +2627,7 @@ exports[`Mega Menu Default renders correctly with extra attributes 1`] = `
>
<span
class="ecl-mega-menu__info-title"
id="about-the-ec-title-id"
>
About the European Commission
</span>
Expand All @@ -2627,6 +2640,7 @@ exports[`Mega Menu Default renders correctly with extra attributes 1`] = `
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-ec-title-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -2748,6 +2762,7 @@ exports[`Mega Menu Default renders correctly with extra attributes 1`] = `
>
<span
class="ecl-mega-menu__info-title"
id="about-key-priorities-id"
>
About key priorities
</span>
Expand Down Expand Up @@ -3213,6 +3228,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the featu
>
<span
class="ecl-mega-menu__info-title"
id="about-the-news-id"
>
About the News and Media
</span>
Expand All @@ -3225,6 +3241,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the featu
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-news-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -3635,6 +3652,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the featu
>
<span
class="ecl-mega-menu__info-title"
id="about-the-ec-title-id"
>
About the European Commission
</span>
Expand All @@ -3647,6 +3665,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the featu
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-ec-title-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -3768,6 +3787,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the featu
>
<span
class="ecl-mega-menu__info-title"
id="about-key-priorities-id"
>
About key priorities
</span>
Expand Down Expand Up @@ -4234,6 +4254,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the fist
>
<span
class="ecl-mega-menu__info-title"
id="about-the-news-id"
>
About the News and Media
</span>
Expand All @@ -4246,6 +4267,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the fist
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-news-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -4655,6 +4677,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the fist
>
<span
class="ecl-mega-menu__info-title"
id="about-the-ec-title-id"
>
About the European Commission
</span>
Expand All @@ -4667,6 +4690,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the fist
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-ec-title-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -4788,6 +4812,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the fist
>
<span
class="ecl-mega-menu__info-title"
id="about-key-priorities-id"
>
About key priorities
</span>
Expand Down Expand Up @@ -5253,6 +5278,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the secon
>
<span
class="ecl-mega-menu__info-title"
id="about-the-news-id"
>
About the News and Media
</span>
Expand All @@ -5265,6 +5291,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the secon
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-news-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -5675,6 +5702,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the secon
>
<span
class="ecl-mega-menu__info-title"
id="about-the-ec-title-id"
>
About the European Commission
</span>
Expand All @@ -5687,6 +5715,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the secon
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-ec-title-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -5808,6 +5837,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the secon
>
<span
class="ecl-mega-menu__info-title"
id="about-key-priorities-id"
>
About key priorities
</span>
Expand Down Expand Up @@ -6273,6 +6303,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the see a
>
<span
class="ecl-mega-menu__info-title"
id="about-the-news-id"
>
About the News and Media
</span>
Expand All @@ -6285,6 +6316,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the see a
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-news-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -6694,6 +6726,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the see a
>
<span
class="ecl-mega-menu__info-title"
id="about-the-ec-title-id"
>
About the European Commission
</span>
Expand All @@ -6706,6 +6739,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the see a
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-ec-title-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -6827,6 +6861,7 @@ exports[`Mega Menu Default renders correctly with extra attributes for the see a
>
<span
class="ecl-mega-menu__info-title"
id="about-key-priorities-id"
>
About key priorities
</span>
Expand Down Expand Up @@ -7292,6 +7327,7 @@ exports[`Mega Menu Default renders correctly with extra class names 1`] = `
>
<span
class="ecl-mega-menu__info-title"
id="about-the-news-id"
>
About the News and Media
</span>
Expand All @@ -7304,6 +7340,7 @@ exports[`Mega Menu Default renders correctly with extra class names 1`] = `
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-news-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -7713,6 +7750,7 @@ exports[`Mega Menu Default renders correctly with extra class names 1`] = `
>
<span
class="ecl-mega-menu__info-title"
id="about-the-ec-title-id"
>
About the European Commission
</span>
Expand All @@ -7725,6 +7763,7 @@ exports[`Mega Menu Default renders correctly with extra class names 1`] = `
Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<a
aria-describedby="about-the-ec-title-id"
class="ecl-link ecl-link--standalone ecl-link--icon ecl-mega-menu__info-link"
href="/example"
>
Expand Down Expand Up @@ -7846,6 +7885,7 @@ exports[`Mega Menu Default renders correctly with extra class names 1`] = `
>
<span
class="ecl-mega-menu__info-title"
id="about-key-priorities-id"
>
About key priorities
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
{# Info #}
{% if _info is not empty %}
{% set _info_classes = 'ecl-mega-menu__info' %}
{% set _info_title_id = (_info.title_id|default('') is not empty) ? _info.title_id : 'ecl-mega-menu__info-title-' ~ random() %}
{% if _info.link is not empty %}
{% set _info_classes = _info_classes ~ ' ecl-mega-menu__info--has-link' %}
{% endif %}
Expand All @@ -154,7 +155,12 @@
data-ecl-mega-menu-mega
>
{% if _info.title is not empty %}
<span class="ecl-mega-menu__info-title">{{ _info.title }}</span>
<span
class="ecl-mega-menu__info-title"
id="{{ _info_title_id }}"
>
{{- _info.title -}}
</span>
{% endif %}
<div class="ecl-mega-menu__info-scrollable">
{%- if _info.content is not empty -%}
Expand All @@ -173,6 +179,9 @@
size: 'xs',
},
extra_classes: _info.link.extra_classes|default('') ~ ' ecl-mega-menu__info-link',
extra_attributes: [{
name: 'aria-describedby', value: _info_title_id,
}],
}) only %}
{%- endif -%}
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/specs/components/mega-menu/demo/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = {
path: exampleLink,
info: {
title: 'About the News and Media',
title_id: 'about-the-news-id',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need to set a new parameter for this? Couldn't we just generate a unique id based on the global mega menu id?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the usual situation where we need to generate ids but we cannot use those for the tests, if you prefer i can remove these from the specs and only add them in the tests, in the template if this is not provided an automatic id is generated

content:
'Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.',
link: {
Expand Down Expand Up @@ -110,6 +111,7 @@ module.exports = {
path: exampleLink,
info: {
title: 'About the European Commission',
title_id: 'about-the-ec-title-id',
content:
'Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.',
link: {
Expand All @@ -129,6 +131,7 @@ module.exports = {
path: exampleLink,
info: {
title: 'About key priorities',
title_id: 'about-key-priorities-id',
content:
'Description text, lorem ipsum dolor sit amet, consectetur adipiscing elit.',
},
Expand Down
Loading