How can I change the variable of class?

Hello, I’m making a custom editor window. I have a Item class, which has 2 variables as string itemName and List itemFeatures(ItemFeature is also a class that I created) I have stated the problems in script with comment
My script;

    void OnGUI()
    {
        EditorGUILayout.LabelField("Items");
        EditorGUILayout.Separator();
        GUILayout.BeginVertical();
        Item chosenItem = new Item();
        for (int a = 0; a < Items.Count; a++)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(Items[a].itemName))
            {
                chosenItem = Items[a];
            }
            if(GUILayout.Button("Delete Item"))
            {
                Items.Remove(Items[a]);
            }
            GUILayout.EndHorizontal();
        }
        GUILayout.EndVertical();

        EditorGUILayout.Separator();
        GUILayout.BeginVertical();
        if (GUILayout.Button("Add Item"))
        {
            Items.Add(new Item());
        }
        GUILayout.EndVertical();
        EditorGUILayout.Separator();
        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("Item Properties: "+chosenItem.itemName);
        if(Items.Count>0)
        {
            chosenItem.itemName=EditorGUILayout.TextField(chosenItem.itemName); //this is not changing the name
            EditorGUILayout.LabelField("Item Features");
            for(int a = 0; a < chosenItem.itemFeatures.Count; a++)
            {
                GUILayout.Button(chosenItem.itemFeatures[a].value+"");
            }
            if(GUILayout.Button("Add Feature"))
            {
                Debug.Log(chosenItem.itemFeatures.Count);
                chosenItem.itemFeatures.Add(new ItemFeature());//this is not adding a new itemFeature
                this.Repaint();
            }
        }
        EditorGUILayout.EndVertical();
    }

}
[System.Serializable]
public class Item
{
        public string itemName="";
        public List<ItemFeature> itemFeatures= new List<ItemFeature>();
}
public class ItemFeature
{
    public enum type { damage, defence, maxHP };
    public int value;
}

as you see, I’m trying to change the itemName, and itemFeatures variables, but they are always the same. Even though I do “Add Feature” chosenItem.itemFeatures.Add(new ItemFeature()); it never adds a new ItemFeathure and itemFeatures.Count is always zero. What am I missing?

chosenItem is declared insde of OnGUI so it gets reset every frame. Move it outside of the function.

Item chosenItem = new Item();
void OnGUI()
{
     EditorGUILayout.LabelField("Items");
     EditorGUILayout.Separator();
     GUILayout.BeginVertical();
     //Item chosenItem = new Item();