diff --git a/js/component/card/floor_plan_editor.js b/js/component/card/floor_plan_editor.js index 8fba94d..771625b 100644 --- a/js/component/card/floor_plan_editor.js +++ b/js/component/card/floor_plan_editor.js @@ -163,12 +163,22 @@ beestat.component.card.floor_plan_editor.prototype.decorate_drawing_pane_ = func // Activate the currently active room (mostly for rerenders). if (room === self.state_.active_room) { room_entity.set_active(true); + } else { + // Render the room and save to the list of current entities. + room_entity.render(self.floor_plan_.get_g()); + self.entities_.room.push(room_entity); } - - // Render the room and save to the list of current entities. - room_entity.render(self.floor_plan_.get_g()); - self.entities_.room.push(room_entity); }); + + /** + * If there was an active room, defer to adding it last so it ends up on + * top. The set_active function doesn't do anything if the room isn't + * rendered otherwise. + */ + if (this.state_.active_room_entity !== undefined) { + this.state_.active_room_entity.render(this.floor_plan_.get_g()); + this.entities_.room.push(this.state_.active_room_entity); + } }; /** diff --git a/js/component/floor_plan_entity.js b/js/component/floor_plan_entity.js index 4ea7826..a663af6 100644 --- a/js/component/floor_plan_entity.js +++ b/js/component/floor_plan_entity.js @@ -81,7 +81,7 @@ beestat.component.floor_plan_entity.prototype.rerender = function() { /** * Bring the current element to the front. */ -beestat.component.floor_plan_entity.prototype.bring_to_front = function() { +beestat.component.floor_plan_entity.prototype.bring_to_front_ = function() { if (this.rendered_ === true) { this.g_.parentNode.appendChild(this.g_); } diff --git a/js/component/floor_plan_entity/room.js b/js/component/floor_plan_entity/room.js index 2112071..a4baced 100644 --- a/js/component/floor_plan_entity/room.js +++ b/js/component/floor_plan_entity/room.js @@ -256,9 +256,9 @@ beestat.component.floor_plan_entity.room.prototype.set_active = function(active) this.dispatchEvent('activate'); this.update_snap_points_(); - this.bring_to_front(); + + this.bring_to_front_(); } else { - // throw 'foo'; delete this.state_.active_room; delete this.state_.active_room_entity;