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

UHF-X accordion state fix & accessibility fix #583

Merged
merged 5 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion dist/js/accordion.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/js/accordion/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export default class State {
this.pageAccordionStates = {};
} else {
this.siteAccordionStates = siteAccordions;
this.pageAccordionStates = this.siteAccordionStates[this.page] === undefined ? {} : this.siteAccordionStates[this.page];
this.siteAccordionStates[this.page] = this.siteAccordionStates[this.page] === undefined ? {} : this.siteAccordionStates[this.page];
this.pageAccordionStates = this.siteAccordionStates[this.page];
}
}

Expand Down
4 changes: 2 additions & 2 deletions templates/component/accordion.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<div class="accordion__wrapper helfi-accordion-item" data-accordion-id="{{heading[0]['#context']['value']|clean_class}}">
<{{ heading_level|default('h2') }} class="accordion-item__header helfi-accordion__header" data-accordion-id="{{heading[0]['#context']['value']|clean_class}}">
<button class="accordion-item__button accordion-item__button--toggle helfi-accordion__header__button" aria-expanded="true" aria-controls="{{ controlled_content_id }}">
<button type="button" class="accordion-item__button accordion-item__button--toggle helfi-accordion__header__button" aria-expanded="true" aria-controls="{{ controlled_content_id }}">
{% if heading_icon %}
<div class="accordion-item__icon">
{% include '@hdbt/misc/icon.twig' ignore missing with {icon: heading_icon} %}
Expand All @@ -27,7 +27,7 @@

{{ content|default('Missing content'|t) }}

<button class="accordion-item__button accordion-item__button--close" aria-controls="{{ controlled_content_id }}" aria-labelledby="{{ close_button_labelled_by_id }}">
<button type="button" class="accordion-item__button accordion-item__button--close" aria-controls="{{ controlled_content_id }}" aria-labelledby="{{ close_button_labelled_by_id }}">
<span class="is-hidden" id="{{ close_button_labelled_by_id }}">{{ 'Close element: '|t({}, {'context': 'The helper text for close accordion visibility button'}) }}{{ heading|default('Missing heading'|t) }}</span>
{{ 'Close'|t }}
</button>
Expand Down