diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index 5a76ba566..12e37b65a 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -29,7 +29,7 @@ @@ -134,6 +138,19 @@ +
+
+

Header

+
+

+ The calculated height of this accordion should be the same + regardless of whether the accordion was collapsed or not + when the height was calculated. +

+
+
+
+ diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index 214753e40..dc50317fb 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -44,6 +44,22 @@ test( "{ active: false }", function() { strictEqual( element.accordion( "option", "active" ), 0 ); }); +// http://bugs.jqueryui.com/ticket/11938 +test( "{ active: false, collapsible: true }", function() { + expect( 1 ); + var element = $( "#collapsible" ).accordion(), + height = element.outerHeight(); + + element + .accordion( "destroy" ) + .accordion( { + active: false, + collapsible: true + } ) + .accordion( "option", "active", 0 ); + equal( element.outerHeight(), height ); +} ); + test( "{ active: Number }", function() { expect( 8 ); var element = $( "#list1" ).accordion({ diff --git a/ui/accordion.js b/ui/accordion.js index 98c8412cc..483de5010 100644 --- a/ui/accordion.js +++ b/ui/accordion.js @@ -360,9 +360,16 @@ return $.widget( "ui.accordion", { } else if ( heightStyle === "auto" ) { maxHeight = 0; this.headers.next() - .each(function() { + .each( function() { + var isVisible = $( this ).is( ":visible" ); + if ( !isVisible ) { + $( this ).show(); + } maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() ); - }) + if ( !isVisible ) { + $( this ).hide(); + } + } ) .height( maxHeight ); } },