EditorGUILayout.TextField changes back to first value I input [GIF of the problem inside]

When I input for example “aaa” in that text from the custom editor and then change it from another code. and then i click on the field again, my initial input “aaa” is set as the current value.

here is the full code:

public class TestingBug : EditorWindow {

string abc = "0";
int num = 0;

[MenuItem("aaa/bbb")] 
static void GettingWindow()
{
    GetWindow<TestingBug>();
}

private void OnGUI()
{
    abc = EditorGUILayout.TextField(abc, GUILayout.Width(200));

    num++;
    abc = num.ToString();

}

}

While textField control is focused, it saves value you pressed and doesn’t feel changes made from code. Try this and look what happens:

public class TestingBug : EditorWindow {
        string abc = "0";
        int num = 0;
        [MenuItem("aaa/bbb")]
        static void GettingWindow () {
            GetWindow<TestingBug>();
        }
        private void OnGUI () {
            abc = EditorGUILayout.TextField(abc, GUILayout.Width(200));
            abc = EditorGUILayout.TextField(abc, GUILayout.Width(200));
            num++;
            abc = num.ToString();
        }
    }