yii2-bootstrap4 icon indicating copy to clipboard operation
yii2-bootstrap4 copied to clipboard

In accordion I cannot set all items to be closed by default.

Open algsupport opened this issue 3 years ago • 4 comments

What steps will reproduce the problem?

Create an accordion widget with any number of groups.

What's expected?

All accordion groups to be closed by default.

What do you get instead?

First group is always rendered showing not matter what options I set.

Additional info

Q A
Yii vesion Latest
PHP version 8.0
Operating system Windows 10

Hi everyone,

I am trying to created an accordion widget that by default has all it's groups not showing, but instead the first group is always showing by default.

I tried reading the source code from accordion.php it seems that the BC fix is enforcing this behavior without any option to configure it.

Did I miss anything? Appreciate your input. Regards

algsupport avatar Feb 07 '22 19:02 algsupport

What about setting

[
    'items' => [
        [
            // [...],
            'expand' => false
        ]
    ]
]

simialbi avatar Feb 07 '22 20:02 simialbi

@simialbi thank you for your response. I believe I have tried it. I will check again and update you, but I would like to get your attention to these lines of code:

https://github.com/yiisoft/yii2-bootstrap4/blob/a0280a6caefbf153ab49664c9ef129675dd02040/src/Accordion.php#L138-L146

If I am not mistaken, it means that if none of the items have expand set to true, then set expand to true for the first item/group. Please correct me if I am wrong.

Thank you for your time Regards

PS. I have already fixed the issue in my code. I just extended the class and overridden the function and it works for me.

algsupport avatar Feb 07 '22 22:02 algsupport

@algsupport you're right, it's done because of compatibility with yii\bootstrap\Collapse

simialbi avatar Feb 08 '22 13:02 simialbi

@simialbi I got that. But I think there should be a way to explicitly disable that behavior.

Regards

algsupport avatar Feb 08 '22 13:02 algsupport