From 252d3aaa79e199898fc4c4c3a4778fdde7b98a61 Mon Sep 17 00:00:00 2001 From: AssisrMatheus Date: Mon, 16 Sep 2019 21:45:56 -0300 Subject: [PATCH] :bug: Fixed a bug where the user could try to edit a previously deleted item --- components/TodoChecklister.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/TodoChecklister.lua b/components/TodoChecklister.lua index 55a2390..8f74ba5 100644 --- a/components/TodoChecklister.lua +++ b/components/TodoChecklister.lua @@ -17,7 +17,9 @@ function TodoChecklisterFrame:AddItem(text) if(self.selectedItem == 0) then table.insert(TodoChecklisterDB, #TodoChecklisterDB+1, { text=text, isChecked=false }) else - TodoChecklisterDB[self.selectedItem].text = text + if (TodoChecklisterDB and TodoChecklisterDB[self.selectedItem]) then + TodoChecklisterDB[self.selectedItem].text = text + end self:ClearSelected() end self:OnUpdate() @@ -28,6 +30,11 @@ function TodoChecklisterFrame:RemoveItem(text) local indexToRemove = TableUtils:IndexOf(TodoChecklisterDB, function(x) return x.text == text end) if(indexToRemove > 0) then + if (self.selectedItem == indexToRemove) then + self:ClearSelected() + TodoChecklister.TodoText:ClearFocus() + end + table.remove(TodoChecklisterDB, indexToRemove) self:OnUpdate() end