Skip to content

Commit f802bef

Browse files
authored
Merge pull request #26 from github/fix-bug-25
Fix: Compute the task list item index correctly.
2 parents f6888ca + fdaa68a commit f802bef

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/task-lists-element.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ function position(checkbox: HTMLInputElement): [number, number] {
132132
const list = taskList(checkbox)
133133
if (!list) throw new Error('.contains-task-list not found')
134134
const item = checkbox.closest('.task-list-item')
135-
const index = item ? Array.from(list.children).indexOf(item) : -1
135+
const listItems = Array.from(list.children).filter(el => el.classList.contains('task-list-item'))
136+
const index = item ? listItems.indexOf(item) : -1
136137
return [listIndex(list), index]
137138
}
138139

0 commit comments

Comments
 (0)