Skip to content

Commit

Permalink
🐛 Fixed a bug where the user could try to edit a previously deleted item
Browse files Browse the repository at this point in the history
  • Loading branch information
AssisrMatheus committed Sep 17, 2019
1 parent 0fbe93b commit 252d3aa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/TodoChecklister.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 252d3aa

Please sign in to comment.