Use case: embedding a view which holds an accordion inside another view also displaying as accordion.

Currently the accordions do not work as expected (independently of eachother).

To reproduce you can use views_field_view module.

Proposed solution: Change the accordion header class to be unique per accordion.

Comments

Nor4a created an issue. See original summary.

nor4a’s picture

nor4a’s picture

StatusFileSize
new1.27 KB
manuel garcia’s picture

Status: Active » Needs work

Thanks @Nor4a for the patch!

First a note that we follow drupal's coding standards on this project :)

On your patch:

  • we use 2 spaces for tabulation
  • if / else statements should start a new line
  • and a few other things

Not a show stopper of course but it means the maintainer would have to spend more time to clean up your patch before committing which might get in the way of your patches getting accepted ;-)

About the patch itself, I will eventually find the time to play around with it. For now after a quick read, I can tell you that I'm not terribly a fan of using a static variable for this, and would like more people to test it and have a look at it in the mean time.

nor4a’s picture

StatusFileSize
new1.24 KB

Fixed coding issues and simplified the patch (without static variable).
It seams that previous version did not work with PHP 7.

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new547 bytes
new7.21 KB

Thanks @Nor4a for following up. #5 looks a lot better.

I spent some time on this today. tested using views_field_view:

+++ b/views-accordion.js
@@ -45,6 +45,12 @@
+          ¶
+          //fix height of the accordeon if it was display:none prior to initialisation
+          $('.ui-accordion-header', $display).click(function(){ ¶
+            $(this).siblings('.ui-accordion-content').css('height','auto');
+            $(this).parents('.ui-accordion-content').css('height','auto');
+          });          ¶

This is not necessary. You can simply set heightStyle to content in the accordion settings, and the nested accordion's content will show up fine. We should probably document this so that people doing nested accordions are aware of it.
Nested accordion content height fix

I have reworked your patch a bit so it applies to 8.1.x. It's just a one line change now.

I would like others to test this before committing it, specially people with running sites since we are changing one class that perhaps themers were relaying on.

manuel garcia’s picture

Issue summary: View changes
manuel garcia’s picture

StatusFileSize
new1.99 KB
new2.07 KB

I've had a thought about this, and we should keep the previous css class in place, and add the new one with the dom_id besides it, so not to break current installations that might have used this for theming already.

Attached patch does this, please kindly test and report what you find =)

  • Manuel Garcia committed 8aeba16 on 8.x-1.x
    Issue #2854861 by Nor4a, Manuel Garcia: Support for nested accordion (...
manuel garcia’s picture

Status: Needs review » Fixed
heddn’s picture

If I nested a view inside of a view, inside of a 3rd view, this still doesn't seem to work.

manuel garcia’s picture

Thanks for testing @heddn!
Was any of the three the same view / display? (wondering if they had the same dom_id)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.