Repository: godotengine/godot (language: cpp)

Issue:
`ERROR: Must be an ancestor of the control.` when reordering `Array` inside Project Settings
### Tested versions

- Reproducable in Godot 4.4
- Reproducable in Godot 4.3

### System information

Godot v4.4.stable - Windows 11 (build 26100) - Multi-window, 4 monitors - Vulkan (Forward+) - dedicated AMD Radeon RX 6900 XT (Advanced Micro Devices, Inc.; 32.0.13031.3015) - AMD Ryzen 9 5900X 12-Core Processor (24 threads)

### Issue description

When reordering an entry inside an `Array` in the `Project Settings` (also happens inside the editor settings), the following error appears in the console: `Must be an ancestor of the control.`

This error is printed by the `ScrollContainer::ensure_control_visible` method.

### Steps to reproduce

1. Open the `Project Settings`
2. Navigate to the `Rendering > GL Compatibility` setting
3. Open the `Force Angle on Devices` setting
4. Reorder an entry with the left button

![Image](https://github.com/user-attachments/assets/68a80142-9c3d-4b80-99f1-61cf7e34db39)

### Minimal reproduction project (MRP)

Not needed, can be reproduced on every project.


Discussion / hints:
So it looks like the `editor_properties_array_dict.cpp` always uses the 
`InspectorDock::get_inspector_singleton()->ensure_control_visible(..)` method to scroll. 

The problem here is, that we are not in the `Inspector Dock`, but in the `Project Settings`. 
This dependency does not seem like a good idea, since the property editors are not just used in the `Inspector Dock`. Maybe this can be solved with a signal or something similar instead.

Fix patch:
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index b4c787103704..f8f21120364d 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -897,8 +897,12 @@ void EditorPropertyArray::_reorder_button_gui_input(const Ref<InputEvent> &p_eve
 				// Automatically move to the next/previous page.
 				_page_changed(page_index + direction);
 			}
-			// Ensure the moving element is visible.
-			InspectorDock::get_inspector_singleton()->ensure_control_visible(reorder_slot.container);
+			// Ensure the moving element is visible in the root inspector.
+			EditorInspector *parent_inspector = get_parent_inspector();
+			if (parent_inspector) {
+				// Defer to prevent moving elements from not displaying properly, especially near borders.
+				callable_mp((ScrollContainer *)parent_inspector->get_root_inspector(), &ScrollContainer::ensure_control_visible).call_deferred(reorder_slot.container);
+			}
 		}
 	}
 }


Test patch: