From cb7bb7bb42a66c93dd0400139d4a7da1b7b57b42 Mon Sep 17 00:00:00 2001 From: Alyosha Pushak Date: Sun, 12 Apr 2015 19:17:16 -0700 Subject: [PATCH 1/5] Accordion: correct height calculated when closed Fixes #11938 --- ui/accordion.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/accordion.js b/ui/accordion.js index 64635271586..e3a0c829361 100644 --- a/ui/accordion.js +++ b/ui/accordion.js @@ -361,7 +361,10 @@ return $.widget( "ui.accordion", { maxHeight = 0; this.headers.next() .each( function() { + var display = $( this ).css( "display" ); + $( this ).css( "display", "block" ); maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() ); + $( this ).css( "display", display ); } ) .height( maxHeight ); } From 6a36202cd7ba4abbd549656be69c90cd93a2d484 Mon Sep 17 00:00:00 2001 From: Alyosha Pushak Date: Mon, 20 Apr 2015 21:14:21 -0700 Subject: [PATCH 2/5] Accordion: correct height calculated when closed Fixes #11938 --- ui/accordion.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/accordion.js b/ui/accordion.js index e3a0c829361..c3f32336bf2 100644 --- a/ui/accordion.js +++ b/ui/accordion.js @@ -361,10 +361,14 @@ return $.widget( "ui.accordion", { maxHeight = 0; this.headers.next() .each( function() { - var display = $( this ).css( "display" ); - $( this ).css( "display", "block" ); + var isVisible = $( this ).is ( ":visible" ); + if ( !isVisible ) { + $( this ).show(); + } maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() ); - $( this ).css( "display", display ); + if ( !isVisible ) { + $( this ).hide(); + } } ) .height( maxHeight ); } From 693c9a5d07b1e12b4ae67be366c3e95c473e8400 Mon Sep 17 00:00:00 2001 From: Alyosha Pushak Date: Tue, 21 Apr 2015 22:14:56 -0700 Subject: [PATCH 3/5] Accordian: correct height calculated when closed white space correction --- ui/accordion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/accordion.js b/ui/accordion.js index c3f32336bf2..00af1d62145 100644 --- a/ui/accordion.js +++ b/ui/accordion.js @@ -361,7 +361,7 @@ return $.widget( "ui.accordion", { maxHeight = 0; this.headers.next() .each( function() { - var isVisible = $( this ).is ( ":visible" ); + var isVisible = $( this ).is( ":visible" ); if ( !isVisible ) { $( this ).show(); } From 9b720f8c5a36fb7e258f5ae024443e07f848ea3c Mon Sep 17 00:00:00 2001 From: Alyosha Pushak Date: Wed, 22 Apr 2015 22:04:12 -0700 Subject: [PATCH 4/5] Accordion: unit test for collapsed height --- tests/unit/accordion/accordion.html | 19 ++++++++++++++++++- tests/unit/accordion/methods.js | 12 ++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index 683b87456cb..ce58567552b 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -8,12 +8,16 @@ @@ -109,6 +113,19 @@

Drums

+
+
+

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/methods.js b/tests/unit/accordion/methods.js index efabfed10b1..3be2c763b07 100644 --- a/tests/unit/accordion/methods.js +++ b/tests/unit/accordion/methods.js @@ -10,6 +10,18 @@ var equalHeight = testHelper.equalHeight, module( "accordion: methods", setupTeardown() ); +test( "collapsedHeight", function() { + expect( 1 ); + var element = $( "#collapsible" ).accordion(), + content = element.find( ".ui-accordion-content" ), + height = content.height(); + element.accordion( "destroy" ).accordion({ + active: false, + collapsible: true + }); + equal( content.height(), height ); +}); + test( "destroy", function( assert ) { expect( 1 ); assert.domEqual( "#list1", function() { From 46e065ea6453c1b88b84a377f590341fa1d57dbc Mon Sep 17 00:00:00 2001 From: Alyosha Pushak Date: Thu, 23 Apr 2015 20:31:56 -0700 Subject: [PATCH 5/5] Accordion: unit test for collapsed height Ref #11938 --- tests/unit/accordion/methods.js | 12 ------------ tests/unit/accordion/options.js | 13 +++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/unit/accordion/methods.js b/tests/unit/accordion/methods.js index 3be2c763b07..efabfed10b1 100644 --- a/tests/unit/accordion/methods.js +++ b/tests/unit/accordion/methods.js @@ -10,18 +10,6 @@ var equalHeight = testHelper.equalHeight, module( "accordion: methods", setupTeardown() ); -test( "collapsedHeight", function() { - expect( 1 ); - var element = $( "#collapsible" ).accordion(), - content = element.find( ".ui-accordion-content" ), - height = content.height(); - element.accordion( "destroy" ).accordion({ - active: false, - collapsible: true - }); - equal( content.height(), height ); -}); - test( "destroy", function( assert ) { expect( 1 ); assert.domEqual( "#list1", function() { diff --git a/tests/unit/accordion/options.js b/tests/unit/accordion/options.js index c95738c4395..82ca625e49a 100644 --- a/tests/unit/accordion/options.js +++ b/tests/unit/accordion/options.js @@ -48,6 +48,19 @@ 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(), + content = element.find( ".ui-accordion-content" ), + height = content.height(); + element.accordion( "destroy" ).accordion({ + active: false, + collapsible: true + }); + equal( content.height(), height ); +}); + test( "{ active: Number }", function() { expect( 8 ); var element = $( "#list1" ).accordion({