Hi,
I'm trying to get the accordions to work and it's almost there.
Now if I have multiple groups, the last accordion item will stay open. I would like them to all be closed by default.
I tried changing maybe the first one to open and there was no change.
Any suggestions is appreciated.
Thank you

Comments

surfkid created an issue. See original summary.

lblissett’s picture

Yes, i am struggling with exact the same behavior. The last accordion item always stays open.

lblissett’s picture

@surfkid:

What you can try is this:

Change here:
src/Element/AccordionItem.php
one line of code in the module for the accodion item from TRUE to FALSE like this (and make a cache rebuild afterwards).

public function getInfo() {
    $class = get_class($this);

    return [
      '#process' => [
        [$class, 'processGroup'],
      ],
      '#pre_render' => [
        [$class, 'preRenderGroup'],
      ],
      '#open' => FALSE,
      '#theme_wrappers' => ['field_group_accordion_item'],
    ];
  }

At least it seems. that this hack works for me.

surfkid’s picture

That worked! Thank you. This should be committed as well.

cbrody’s picture

Here's a patch I made which seems to resolve the issue.

cbrody’s picture

StatusFileSize
new1.05 KB

Sorry that didn't work, try this one.

cbrody’s picture

Status: Active » Needs review

  • zuuperman committed 043b706 on 8.x-3.x authored by cbrody
    Issue #2984756 by cbrody: Accordion/Default State doesn't do anything
    
nils.destoop’s picture

Status: Needs review » Fixed

Thx for the patch. I have committed this to dev

johnpitcairn’s picture

Status: Fixed » Closed (fixed)
johnpitcairn’s picture

(sorry that was unintentional)