Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Enh #306: Raise `yiisoft/html` version to `^3.13 || ^4.0` (@vjik)
- New #305: Add `tabIndex()` method to `Button` widget (@Mister-42)
- Bug #309: Fix `Collapse` re-encoding content already managed by `Toggler` (@vjik)

## 1.1.0 March 06, 2026

Expand Down
9 changes: 2 additions & 7 deletions src/Collapse.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,9 @@ public function render(): string
->addAttributes($this->attributes)
->addContent(
"\n",
(new Div())
->addAttributes($this->cardBodyAttributes)
Html::div("\n" . $item->getContent() . "\n", $this->cardBodyAttributes)
->addClass(self::CARD, self::CARD_BODY)
->addContent(
"\n",
$item->getContent(),
"\n",
),
->encode(false),
"\n",
)
->id($item->getId());
Expand Down
11 changes: 11 additions & 0 deletions tests/CollapseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use InvalidArgumentException;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\TestWith;
use PHPUnit\Framework\TestCase;
use Yiisoft\Bootstrap5\Collapse;
use Yiisoft\Bootstrap5\Tests\Support\Assert;
Expand Down Expand Up @@ -475,4 +476,14 @@ public function testTogglerContainerTag(): void
->render(),
);
}

#[TestWith(['<b>Bold content</b>', true])]
#[TestWith(['<b>Bold content</b>', false])]
public function testTogglerHtmlContent(string $expected, bool $encode): void
{
$toggler = Toggler::for('<b>Bold content</b>', 'collapseExample', encode: $encode)->togglerContent('Toggle');
$widget = Collapse::widget()->items($toggler);

$this->assertStringContainsString($expected, $widget->render());
}
}
Loading