Skip to content

Commit 70b1647

Browse files
committed
Merge pull request godotengine#104785 from Rindbee/fix-root-inspector-follow_focus-set-to-true
Fix setting root inspector's `follow_focus` to `true` when `update_tree()` method ends
2 parents 3e9f624 + 9996bf3 commit 70b1647

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

editor/editor_inspector.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3281,14 +3281,21 @@ bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName
32813281
}
32823282

32833283
void EditorInspector::update_tree() {
3284+
if (!object) {
3285+
return;
3286+
}
3287+
3288+
bool root_inspector_was_following_focus = get_root_inspector()->is_following_focus();
3289+
if (root_inspector_was_following_focus) {
3290+
// Temporarily disable focus following on the root inspector to avoid jumping while the inspector is updating.
3291+
get_root_inspector()->set_follow_focus(false);
3292+
}
3293+
32843294
// Store currently selected and focused elements to restore after the update.
32853295
// TODO: Can be useful to store more context for the focusable, such as the caret position in LineEdit.
32863296
StringName current_selected = property_selected;
32873297
int current_focusable = -1;
32883298

3289-
// Temporarily disable focus following on the root inspector to avoid jumping while the inspector is updating.
3290-
get_root_inspector()->set_follow_focus(false);
3291-
32923299
if (property_focusable != -1) {
32933300
// Check that focusable is actually focusable.
32943301
bool restore_focus = false;
@@ -3310,14 +3317,9 @@ void EditorInspector::update_tree() {
33103317
}
33113318
}
33123319

3313-
// Only hide plugins if we are not editing any object.
3314-
// This should be handled outside of the update_tree call anyway (see EditorInspector::edit), but might as well keep it safe.
3315-
_clear(!object);
3316-
3317-
if (!object) {
3318-
get_root_inspector()->set_follow_focus(true);
3319-
return;
3320-
}
3320+
// The call here is for the edited object that has not changed, but the tree needs to be updated (for example, the object's property list has been modified).
3321+
// Since the edited object has not changed, there is no need to hide the plugin at this time.
3322+
_clear(false);
33213323

33223324
List<Ref<EditorInspectorPlugin>> valid_plugins;
33233325

@@ -4201,7 +4203,9 @@ void EditorInspector::update_tree() {
42014203
EditorNode::get_singleton()->hide_unused_editors();
42024204
}
42034205

4204-
get_root_inspector()->set_follow_focus(true);
4206+
if (root_inspector_was_following_focus) {
4207+
get_root_inspector()->set_follow_focus(true);
4208+
}
42054209
}
42064210

42074211
void EditorInspector::update_property(const String &p_prop) {

0 commit comments

Comments
 (0)