aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlyosha Pushak <alyosha.pushak@gmail.com>2015-04-12 19:17:16 -0700
committerScott González <scott.gonzalez@gmail.com>2016-02-09 14:40:29 -0500
commitc87653bc24f5bc84c299b047d49a06c132a48788 (patch)
treecd19065718aedd23980ef2b5ade800c8a6f81622
parent2bc84615ae306b15e4fed50fb9d2c54e05e62870 (diff)
downloadjquery-ui-c87653bc24f5bc84c299b047d49a06c132a48788.tar.gz
jquery-ui-c87653bc24f5bc84c299b047d49a06c132a48788.zip
Accordion: Correct height calculated when closed
Fixes #11938 Closes gh-1536 Closes gh-1616
-rw-r--r--tests/unit/accordion/accordion.html19
-rw-r--r--tests/unit/accordion/options.js16
-rw-r--r--ui/widgets/accordion.js7
3 files changed, 41 insertions, 1 deletions
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html
index 683b87456..ce5856755 100644
--- a/tests/unit/accordion/accordion.html
+++ b/tests/unit/accordion/accordion.html
@@ -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>
@@ -109,6 +113,19 @@
</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>
diff --git a/tests/unit/accordion/options.js b/tests/unit/accordion/options.js
index c9b2e3aaf..228a8be40 100644
--- a/tests/unit/accordion/options.js
+++ b/tests/unit/accordion/options.js
@@ -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( {
diff --git a/ui/widgets/accordion.js b/ui/widgets/accordion.js
index 14b3f7303..359b4c46f 100644
--- a/ui/widgets/accordion.js
+++ b/ui/widgets/accordion.js
@@ -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 );
}