]> source.dussan.org Git - jquery-ui.git/commitdiff
Accordion: Correct height calculated when closed
authorAlyosha Pushak <alyosha.pushak@gmail.com>
Mon, 13 Apr 2015 02:17:16 +0000 (19:17 -0700)
committerScott González <scott.gonzalez@gmail.com>
Tue, 9 Feb 2016 19:40:29 +0000 (14:40 -0500)
Fixes #11938
Closes gh-1536
Closes gh-1616

tests/unit/accordion/accordion.html
tests/unit/accordion/options.js
ui/widgets/accordion.js

index 683b87456cb4c0e21c4faad981281444ba391a80..ce58567552bbd85d5235f80ff3f5f773d8c2869b 100644 (file)
@@ -8,12 +8,16 @@
        <script src="../../lib/css.js" data-modules="core accordion"></script>
        <script src="../../lib/bootstrap.js" data-widget="accordion"></script>
        <style>
-       #list, #list1 *, #navigation, #navigation * {
+       #list, #list1 *, #navigation, #navigation *, #collapsible, #collapsible * {
                margin: 0;
                padding: 0;
                font-size: 12px;
                line-height: 15px;
        }
+       #collapsibleWrapper {
+               width: 300px;
+               float: left;
+       }
        </style>
 </head>
 <body>
        </dd>
 </dl>
 
+<div id="collapsibleWrapper">
+       <div id="collapsible">
+               <h3>Header</h3>
+               <div>
+                       <p>
+                               The calculated height of this accordion should be the same
+                               regardless of whether the accordion was collapsed or not
+                               when the height was calculated.
+                       </p>
+               </div>
+       </div>
+</div>
+
 </div>
 </body>
 </html>
index c9b2e3aaf159158e7bda44cdbf6f438e8c440b75..228a8be4063aa7c159ec854905eb4e9db27b589d 100644 (file)
@@ -48,6 +48,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( {
index 14b3f730327d65061a8f16ff66f2b13caba0976a..359b4c46f62444844ff9c80fbd05cfbdb4c94da4 100644 (file)
@@ -373,7 +373,14 @@ return $.widget( "ui.accordion", {
                        maxHeight = 0;
                        this.headers.next()
                                .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 );
                }