From 8a43a16f6b40d0bac8f2c63c375f85a5d2e868eb Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Sat, 25 Nov 2023 18:39:02 +0100 Subject: [PATCH] Fix Reset Layout not working with panel changes --- js/interface/panels.js | 8 ++++++-- js/modes.js | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/js/interface/panels.js b/js/interface/panels.js index a00cd9f1..82bee696 100644 --- a/js/interface/panels.js +++ b/js/interface/panels.js @@ -350,6 +350,11 @@ class Panel extends EventSystem { if (!this.position_data.height) this.position_data.height = defaultp.height || 300; if (this.position_data.folded == undefined) this.position_data.folded = defaultp.folded || false; + for (let mode_id in Interface.data.modes) { + let mode_data = Interface.getModeData(mode_id); + if (!mode_data.panels[this.id]) mode_data.panels[this.id] = JSON.parse(JSON.stringify(this.position_data)); + } + this.moveTo(this.slot); this.fold(this.folded); return this; @@ -538,8 +543,7 @@ class Panel extends EventSystem { return this; } updateSlot() { - let position_data = this.position_data; - let {slot} = position_data; + let slot = this.slot; this.node.classList.remove('floating'); diff --git a/js/modes.js b/js/modes.js index 76fbc9fb..4468094c 100644 --- a/js/modes.js +++ b/js/modes.js @@ -63,7 +63,11 @@ class Mode extends KeybindItem { UVEditor.beforeMoving(); for (let id in Panels) { + let old_pos_data = Panels[id].position_data; Panels[id].position_data = Interface.getModeData().panels[id]; + if (!Panels[id].position_data) { + Panels[id].position_data = Interface.getModeData().panels[id] = JSON.parse(JSON.stringify(old_pos_data)) + } Panels[id].updateSlot(); } updateSidebarOrder();