godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.17k stars 20.22k forks source link

(4.4.dev2) Inspecting an exported typed dictionary while editing a script grabs the focus away from the script editor #96913

Open Mashmashin opened 1 week ago

Mashmashin commented 1 week ago

Tested versions

4.4.dev2

System information

Windows 11 - Godot 4.4.dev2 - Vulkan(Forward+)

Issue description

If you have typed dictionary open in the inspector (so you can edit the values), it will grab the focus away from script editor everytime it has done checking for errors.

Here's a video I am experiencing

Steps to reproduce

  1. Create a script with export variable that is any kind of typed dictionary.
  2. Attach it to a node and click the node so you can see the exported typed dictionary.
  3. In inspector, open the dictionary so the keys and values are shown in the inspector.
  4. Edit script in the script editor in any way and wait for the script editor to check for errors.
  5. The typed dictionary's "New Value" should grab the focus away from the script editor. This is very noticeable if you change the "text_editor/completion/idle_parse_delay" in EditorSettings to a very low value.

Minimal reproduction project (MRP)

dictionary_issue.zip

AThousandShips commented 1 week ago

Haven't confirmed but should be caused by this code: https://github.com/godotengine/godot/blob/83d54ab2ad476ae265b323c2b88f4623b922f4c6/editor/editor_properties_array_dict.cpp#L1178-L1183

But can't see how it is affected specifically by typed dictionaries, but confirmed that non-typed dictionaries won't trigger this

CC @Repiteo

Dowsley commented 1 week ago

@AThousandShips I found that grab_focus skips focusing with an early return, but only for non-typed arrays. I believe it has to do with the default value that only appears for typed ones, e.g. 0 for int values.

Do you mind if I try fixing this?