When you add n elements to the app, then go to the active tab and start toggling the tasks from top to bottom, the bottom tasks will re-toggle the top tasks. This is because of the way the filtering is done.
Suppose we have the following tasks, ["task1", "task2", "task3", "task4"], and only "task4" is active.
When the Active filter is applied, we get an iterator containing only ["task4"] and because the program uses .enumerate(), it gives "task4" the index 0 because it's the only element in the active tasks. So, when we toggle "task4" which has the index 0, the program instead toggles ["task1"]. That is, the program uses the index of the filtered tasks to delete from the global vector of tasks.
Another problem?
But I think there's another problem and I just started playing with vgtk so I don't know know if I'm just doing something wrong or not.
After I tried to fix the problem I just described, I noticed that the indices weren't being updated and I think there's an error with the vdom-diffing code.
It doesn't matter what index is passed to Item::render, the value of the index passed to Msg::Filter is always based on the position.
When the item b moves to the old position of a, it acts as if it were a. If I delete or toggle b, the action will be applied to a. Then when c gets to the old position of a or b, the same happens.
Reproduce
When you add n elements to the app, then go to the
active
tab and start toggling the tasks from top to bottom, the bottom tasks will re-toggle the top tasks. This is because of the way the filtering is done.Suppose we have the following tasks,
["task1", "task2", "task3", "task4"]
, and only"task4"
is active.When the
Active
filter is applied, we get an iterator containing only["task4"]
and because the program uses.enumerate()
, it gives"task4"
the index 0 because it's the only element in the active tasks. So, when we toggle"task4"
which has the index 0, the program instead toggles["task1"]
. That is, the program uses the index of the filtered tasks to delete from the global vector of tasks.Another problem?
But I think there's another problem and I just started playing with vgtk so I don't know know if I'm just doing something wrong or not.
After I tried to fix the problem I just described, I noticed that the indices weren't being updated and I think there's an error with the vdom-diffing code.
It doesn't matter what
index
is passed toItem::render
, the value of the index passed toMsg::Filter
is always based on the position.Apply the following patch to see what I mean.
Here's a video showing what I mean: https://streamable.com/1il11r
When the item
b
moves to the old position ofa
, it acts as if it werea
. If I delete or toggleb
, the action will be applied toa
. Then whenc
gets to the old position ofa
orb
, the same happens.Here's my fork with the patch applied: https://github.com/emi2k01/vgtk