Accordion expand/collapse option

Would it be possible to includeon the Accordion resource the option to have the panels expanded or collapsed, or even just a single option to have the first panel expanded?


Auto-expand accordion panel
Content types: 
Issue Status: 
Supporter votes Members of the Supporter Network can vote for feature requests. When the supporter network has generated sufficient funding for the top voted feature request it will normally be implemented and released. More about the H5P Supporter Network
icc's picture

This sounds reasonable and would probably be easy to achieve. Thank you for your suggestion.


I took a stab at doing this. I've attached a patch that does the following:

  • 3 options for expanded/collapsed
  • - all expanded
  • - all collapsed
  • - first only expanded
  • option to have multiple panels open instead of just one

I made sure the defaults stay as it currently is so nothing breaks (all collapsed and only 1 panel open at a time).

Please let me know what you think. Thanks.


PS - I'm new to H5P's code, so please be gentle :)

PPS - I changed the 

if (self.$expandedTitle === undefined || !self.$$title)) {

code because I had trouble understanding it.

if ($(this).hasClass("h5p-panel-expanded")) {

was easier for me to understand and step through. There may be reasons why changing this is bad. Thanks.

tim's picture

Nice work nmillin, would you be able to create a pull request for this on the accordion repository:

If you need any assistance, I can guide you through the process 

Sorry. I replied to the wrong thread.

tomaj's picture

Hi nmillin,

I created a Jira task, to reivew your pull request. You can follow it here.

- Tom

Sure Tim.

Let me know if I didn't do a proper pull request. Usually I'm submitting Drupal patches which is a different process. Thanks.

tomaj's picture

See my answer above! Always awesome to see pull requests from the community! +1

- Tom