From f9429105aa6ca6a2cc2547a7de94ebda3ad3f030 Mon Sep 17 00:00:00 2001
From: Eric Heine <erheine@nps.edu>
Date: Tue, 26 Oct 2021 15:15:09 -0700
Subject: [PATCH] The item is now removed from the dictionary of list items
 before calling the OnItemRemoved function, but the root GameObject is
 destroyed afterwards just to make sure Unity isn't doing any cleanup before a
 derived class has a chance to.

---
 Sane Eric's UI/DynamicList.cs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Sane Eric's UI/DynamicList.cs b/Sane Eric's UI/DynamicList.cs
index 9847112..26c6387 100644
--- a/Sane Eric's UI/DynamicList.cs	
+++ b/Sane Eric's UI/DynamicList.cs	
@@ -48,9 +48,10 @@ namespace Shared.SEUI {
     // Remove the given item from the list (if it is in the list)
     public void RemoveItem(TValueType item) {
       if (listItems.ContainsKey(item)) {
-        OnItemRemoved(item, listItems[item]);
-        Destroy(listItems[item].gameObject);
+        var itemUI = listItems[item];
         listItems.Remove(item);
+        OnItemRemoved(item, itemUI);
+        Destroy(itemUI.gameObject);
       }
     }
 
-- 
GitLab