Skip to content

Commit

Permalink
Merge pull request #26 from github/fix-bug-25
Browse files Browse the repository at this point in the history
Fix: Compute the task list item index correctly.
  • Loading branch information
koddsson authored Aug 4, 2021
2 parents f6888ca + fdaa68a commit f802bef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/task-lists-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ function position(checkbox: HTMLInputElement): [number, number] {
const list = taskList(checkbox)
if (!list) throw new Error('.contains-task-list not found')
const item = checkbox.closest('.task-list-item')
const index = item ? Array.from(list.children).indexOf(item) : -1
const listItems = Array.from(list.children).filter(el => el.classList.contains('task-list-item'))
const index = item ? listItems.indexOf(item) : -1
return [listIndex(list), index]
}

Expand Down

0 comments on commit f802bef

Please sign in to comment.