From cf8378f426536a0ddbf6b2d9c7d8a8c29ac7716a Mon Sep 17 00:00:00 2001 From: Hilderin <81109165+Hilderin@users.noreply.github.com> Date: Sun, 7 Jul 2024 16:26:29 -0400 Subject: [PATCH] Fix Toggle Last Opened Bottom Panel not working after restoring FileSystem Dock to the side --- editor/gui/editor_bottom_panel.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/editor/gui/editor_bottom_panel.cpp b/editor/gui/editor_bottom_panel.cpp index 3e74a3c94e5..3cb95a39267 100644 --- a/editor/gui/editor_bottom_panel.cpp +++ b/editor/gui/editor_bottom_panel.cpp @@ -188,10 +188,11 @@ Button *EditorBottomPanel::add_item(String p_text, Control *p_item, const Refis_visible_in_tree()) { - _switch_to_item(false, i); + was_visible = true; } item_vbox->remove_child(items[i].control); button_hbox->remove_child(items[i].button); @@ -200,6 +201,16 @@ void EditorBottomPanel::remove_item(Control *p_item) { break; } } + + if (was_visible) { + // Open the first panel to ensure that if the removed dock was visible, the bottom + // panel will not collapse. + _switch_to_item(true, 0); + } else if (last_opened_control == p_item) { + // When a dock is removed by plugins, it might not have been visible, and it + // might have been the last_opened_control. We need to make sure to reset the last opened control. + last_opened_control = items[0].control; + } } void EditorBottomPanel::make_item_visible(Control *p_item, bool p_visible) {