From a93ad182c837ef6c46323092a5538355e7ee3a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 27 Mar 2013 15:23:59 -0400 Subject: [PATCH] Accordion: Maintain collapsed state on refresh. Fixes #9189 - Accordion: refresh() method incorrectly opens collapsed accordion. (cherry picked from commit 5a8596cdf3baa4d835e588cda9060a0537236c71) --- tests/unit/accordion/accordion_methods.js | 11 ++++++++++- ui/jquery.ui.accordion.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index b1123b828..f81bd6ded 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -30,7 +30,7 @@ test( "enable/disable", function() { }); test( "refresh", function() { - expect( 17 ); + expect( 19 ); var element = $( "#navigation" ) .parent() .height( 300 ) @@ -104,6 +104,15 @@ test( "refresh", function() { element.find( "div.foo" ).eq( 0 ).remove(); element.accordion( "refresh" ); state( element, 1 ); + + // collapse all panels + element.accordion( "option", { + collapsible: true, + active: false + }); + state( element, 0 ); + element.accordion( "refresh" ); + state( element, 0 ); }); test( "widget", function() { diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 1afa95cb4..01fe2c014 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -221,7 +221,7 @@ $.widget( "ui.accordion", { options.active = false; this.active = $(); // active false only when collapsible is true - } if ( options.active === false ) { + } else if ( options.active === false ) { this._activate( 0 ); // was active, but active panel is gone } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {