Empty todo items break the check index
flisk opened this issue · comments
When a document contains empty todo items, any subsequent todo items can no longer be correctly checked or unchecked. This is because the AJAX callback in action.php
does not ignore these empty todo items when it determines item indices.
Example to reproduce the problem:
<todo> </todo>
<todo>not empty</todo>
The first item will not render in the frontend since the rendering code skips items with no content. The second item is rendered and gets a data-index
attribute of 0
. When you try to mark this item as checked, the AJAX call passes that 0
index, but the handler determines the empty todo item to be item 0
and marks that as checked instead, leaving the item that the user intended to check unchanged.
I noticed this bug in a company-internal todo list because someone tried to do what #88 was requesting. Some further consideration towards implementing that feature may be warranted.
The following line and the code after it do not take in account that there could be empty todo tags in the source of the page. it simply searches for the todo with the given index (from ajax call).
dokuwiki-plugin-todo/action.php
Line 130 in 60db5b5
Maybe the search function should get the check for todos to skip:
dokuwiki-plugin-todo/action.php
Line 192 in 60db5b5
Further I guess there is one more issue with this search function: As it takes the raw wiki page there might be more problems as it could find <todo
occurrences in formatted text which should not be taken in account:
<file>
<todo>
</file>
<todo> my todo </todo>
A PR is welcome!