mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 22:31:14 +00:00
Fix removing todo items in node
After removal the index is wrong and I mistakely thought entries() adjuts.
This commit is contained in:
parent
f53997c155
commit
68e35ab332
2 changed files with 10 additions and 3 deletions
|
@ -207,6 +207,10 @@ class ArrayModel<T> implements Model<T> {
|
|||
this.notify.rowRemoved(index, size);
|
||||
}
|
||||
|
||||
get length(): number {
|
||||
return this.a.length;
|
||||
}
|
||||
|
||||
values(): IterableIterator<T> {
|
||||
return this.a.values();
|
||||
}
|
||||
|
|
|
@ -56,9 +56,12 @@ app.todo_added.setHandler(function (text) {
|
|||
})
|
||||
|
||||
app.remove_done.setHandler(function () {
|
||||
for (const [i, item] of model.entries()) {
|
||||
if (item.checked) {
|
||||
model.remove(i, 1);
|
||||
let offset = 0;
|
||||
const length = model.length;
|
||||
for (let i = 0; i < length; ++i) {
|
||||
if (model.rowData(i - offset).checked) {
|
||||
model.remove(i - offset, 1);
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue