Skip to content

Commit

Permalink
Merge pull request #369 from helsingborg-stad/fix/accordion-headings-…
Browse files Browse the repository at this point in the history
…array

fix: accordion aria label array
  • Loading branch information
NiclasNorin authored Jan 23, 2024
2 parents 486ac3c + 1a15812 commit f9131c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion source/php/Component/Accordion__item/Accordion__item.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public function init() {
$this->data['classList'][] = 'c-accordion__section';
$this->data['id'] = uniqid();

$this->data['headingType'] = ( isset($this->heading) && is_array($this->heading) ) ? $this->data['baseClass'] . '__heading-is-array' : '';
$this->data['headingType'] = $this->headingType() ? $this->data['baseClass'] . '__heading-is-array' : '';
$this->data['ariaLabel'] = $this->headingType() ? $this->heading[0] : $this->heading;

//Removes duplicate baseclass (Autogenerated)
if (function_exists('add_filter')) {
Expand All @@ -25,4 +26,8 @@ public function init() {
}, 10, 3);
}
}

private function headingType() {
return isset($this->heading) && is_array($this->heading);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{-- Accordion Item --}}
<{{$sectionElement}} class="{{$class}}" {!! $attribute !!}">
<{{$sectionHeadingElement}} class="{{$baseClass}}__button" aria-label="{{$heading}}" aria-controls="{{ $baseClass }}__aria-{{ $id }}" aria-expanded="false" js-expand-button href="#{{$id}}">
<{{$sectionHeadingElement}} class="{{$baseClass}}__button" aria-label="{{$ariaLabel}}" aria-controls="{{ $baseClass }}__aria-{{ $id }}" aria-expanded="false" js-expand-button href="#{{$id}}">
<div class="{{$baseClass}}__button-wrapper {{$headingType}} " tabindex="-1">

{!!$beforeHeading!!}
Expand Down

0 comments on commit f9131c2

Please sign in to comment.