Accordion missing button collapsed causes all headers to render like uncollapsed
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3330446. -->
Reported by: [prauat](https://www.drupal.org/user/3240621)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Missing collapsed class on accordion header button collapsed causes headers to be rendered with arrow up.<br>
<img src="https://www.drupal.org/files/issues/2022-12-31/Screenshot_20221231_171237.png" alt="buggy accordion display"></p>
<pre>{% set collapse_class = (<br> (i == 1 and options.collapse.first is defined and options.collapse.first > 0)<br> or (i == len and options.collapse.last is defined and options.collapse.last > 0)<br> or (i != 1 and i != len and options.collapse.middle is defined and options.collapse.middle > 0)<br> ) ? 'collapse show' : 'collapse'<br>%}<br>{% set collapse_class_boolean = (<br> (i == 1 and options.collapse.first is defined and options.collapse.first > 0)<br> or (i == len and options.collapse.last is defined and options.collapse.last > 0)<br> or (i != 1 and i != len and options.collapse.middle is defined and options.collapse.middle > 0)<br> ) ? 'true' : 'false'<br>%}<br><br><div class="accordion-item"><br> <h2 class="accordion-header" id="heading{{ key }}"><br> <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#{{ id }}-collapse-{{ key }}" aria-expanded="{{collapse_class_boolean}}" aria-controls="{{ id }}-collapse-{{ key }}"><br> {{ row.title }}<br> </button><br> </h2><br>...</pre><h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>create new accordion view</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<pre> {% set collapse_var = (<br> (i == 1 and options.collapse.first is defined and options.collapse.first > 0)<br> or (i == len and options.collapse.last is defined and options.collapse.last > 0)<br> or (i != 1 and i != len and options.collapse.middle is defined and options.collapse.middle > 0)<br> ) ? true : false<br> %}<br> {% set collapse_class = (collapse_var) ? 'show' %}<br> {% set collapse_class_boolean = (collapse_var) ? 'true' : 'false' %}<br> {% set button_classes = (not collapse_var) ? 'collapsed' %}<br><br> <div class="accordion-item"><br> <h2 class="accordion-header" id="heading{{ key }}"><br> <button class="accordion-button {{button_classes}}" type="button" data-bs-toggle="collapse" data-bs-target="#{{ id }}-collapse-{{ key }}" aria-expanded="{{collapse_class_boolean}}" aria-controls="{{ id }}-collapse-{{ key }}"><br> {{ row.title }}<br> </button><br> </h2><br><br> <div id="{{ id }}-collapse-{{ key }}" class="accordion-collapse collapse {{collapse_class}}" aria-labelledby="heading{{ key }}" data-bs-parent="#{{ id }}"></pre><h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>none</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>n/a</p>
<h3 id="summary-api-changes">API changes</h3>
<p>n/a</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>n/a</p>
>>> [!note] Pre-migration files
- [Screenshot\_20221231\_171237.png](https://www.drupal.org/files/issues/2022-12-31/Screenshot_20221231_171237.png)
>>>
issue
GitLab AI Context
Project: project/views_bootstrap
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/views_bootstrap/-/raw/5.5.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/views_bootstrap
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD