From c943bc32e9b842d644389473f1716ba004784624 Mon Sep 17 00:00:00 2001 From: Simon Karlen Date: Mon, 4 Jul 2022 12:10:54 +0200 Subject: [PATCH] Fixed #43 --- CHANGELOG.md | 1 + src/Accordion.php | 6 +++++- tests/AccordionTest.php | 14 +++++++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 164a296..3d3e2e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 bootstrap5 extension Change Log 2.0.4 under development ----------------------- +- Bug #43: Accordion widget does not set "collapsed" class on toggle button (simialbi) - Enh #39: Add inline mode to `BaseHtml::checkboxList()` and `BaseHtml::radioList()` (WinterSilence) - Enh #40: Breadcrumbs refactoring (WinterSilence) diff --git a/src/Accordion.php b/src/Accordion.php index 6ec2e07..e9c83f2 100644 --- a/src/Accordion.php +++ b/src/Accordion.php @@ -214,7 +214,11 @@ class Accordion extends Widget ArrayHelper::remove($itemToggleOptions, 'data.bs-target'); $headerToggle = Html::a($header, '#' . $id, $itemToggleOptions) . "\n"; } else { - Html::addCssClass($itemToggleOptions, ['widget' => 'accordion-button']); + if (!$expand) { + Html::addCssClass($itemToggleOptions, ['widget' => 'accordion-button collapsed']); + } else { + Html::addCssClass($itemToggleOptions, ['widget' => 'accordion-button']); + } $headerToggle = Button::widget([ 'label' => $header, 'encodeLabel' => false, diff --git a/tests/AccordionTest.php b/tests/AccordionTest.php index 64a0b0e..a5ba014 100644 --- a/tests/AccordionTest.php +++ b/tests/AccordionTest.php @@ -82,14 +82,14 @@ class AccordionTest extends TestCase -
+
Das ist das Haus vom Nikolaus
-
+
    @@ -99,7 +99,7 @@ class AccordionTest extends TestCase
-
+
    @@ -145,19 +145,19 @@ HTML
    Content1
-
+
Content2
-
+
Content3
-
+
@@ -186,7 +186,7 @@ HTML $this->assertEqualsWithoutLE(<< -
+
Content1