diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index b4dafd1736..c17a7ae47a 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -1528,6 +1528,10 @@ void FileDialog::_invalidate() { update_file_list(); + if (ensure_visible_after_invalidating) { + file_list->ensure_current_is_visible(); + ensure_visible_after_invalidating = false; + } is_invalidating = false; } @@ -1621,6 +1625,7 @@ void FileDialog::_sort_option_selected(int p_option) { file_sort_button->get_popup()->set_item_checked(i, (i == p_option)); } file_sort = FileSortOption(p_option); + ensure_visible_after_invalidating = true; invalidate(); } diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 46dbbeb8f2..753ccb99e1 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -205,6 +205,7 @@ private: String full_dir; bool is_invalidating = false; + bool ensure_visible_after_invalidating = false; VBoxContainer *main_vbox = nullptr;