From a1f20ee345620645a12c2be50e405f116bd3c70a Mon Sep 17 00:00:00 2001 From: ahocevar Date: Mon, 13 Sep 2010 13:26:07 +0000 Subject: [PATCH] Avoid panel being displayed after deactivate. p=jorix, r=me (closes #2835) git-svn-id: http://svn.openlayers.org/trunk/openlayers@10732 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/Panel.js | 2 ++ tests/Control/Panel.html | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Control/Panel.js b/lib/OpenLayers/Control/Panel.js index 3af0f31f8c..cccdf2a09a 100644 --- a/lib/OpenLayers/Control/Panel.js +++ b/lib/OpenLayers/Control/Panel.js @@ -95,6 +95,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, { * APIMethod: destroy */ destroy: function() { + this.deactivate(); OpenLayers.Control.prototype.destroy.apply(this, arguments); for(var i = this.controls.length - 1 ; i >= 0; i--) { if(this.controls[i].events) { @@ -143,6 +144,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, { control = this.controls[i]; this.activeState[control.id] = control.deactivate(); } + this.redraw(); return true; } else { return false; diff --git a/tests/Control/Panel.html b/tests/Control/Panel.html index 59018ae508..e52fed2617 100644 --- a/tests/Control/Panel.html +++ b/tests/Control/Panel.html @@ -227,7 +227,26 @@ t.ok(!controlNoDeactive.active, "Tool control autoActivate:true is not active"); } - + function test_Control_Panel_dectivate (t) { + t.plan(3); + var map = new OpenLayers.Map('map'); + var control = new OpenLayers.Control(); + var panel = new OpenLayers.Control.Panel(); + map.addControl(panel); + panel.addControls([control]); + t.ok(panel.div.innerHTML != "", "Panel displayed after activate"); + + panel.deactivate(); + t.ok(panel.div.innerHTML == "", + "Panel is not displayed after deactivate without any active control"); + + panel.activate(); + var div = panel.div; + panel.destroy(); + t.ok(panel.div.innerHTML == "", + "Panel is not displayed after destroy without any active control"); + map.destroy(); + }