Aurelia if.bind dentro de repeat.for não está atualizando
Eu tenho um caso estranho em um modelo Aurelia de elementos com if.bind dentro de um repeat.for não sendo mostrado / oculto quando sua propriedade subjacente é alterada. Com o código a seguir, os campos de edição devem ser mostrados e o botão de edição deve ser oculto assim que o botão de edição é clicado. Posteriormente, os botões salvar e desfazer devem ocultar os campos de edição e mostrar os botões de edição novamente.
MyList.ts:
import { computedFrom } from "aurelia-binding";
export class MyList
{
items: any[] = [{
"firstName": "Joe",
"lastName" : "Blow",
"id": 1
},
{
"firstName": "Jane",
"lastName" : "Doe",
"id": 2
}
]
editingItem: any = null
isEditing: boolean;
edit(item){
this.editingItem = item;
this.isEditing = true;
}
editFirst(item){
this.editingItem = this.items[0];
this.isEditing = true;
}
undo(){
// undo logic here
this.editingItem = null;
this.isEditing = false;
}
save(){
// Save logic here
this.editingItem = null;
this.isEditing = false;
}
}
MyList.html:
<template>
<table>
<tbody>
<tr repeat.for="item of items">
<td if.bind="!isEditing">
<button click.delegate="edit(item)">Edit</button>
</td>
<td>${item.firstName}</td>
<td>${item.lastName}</td>
<td if.bind="isEditing && editingItem.id == item.id">
<button click.delegate="save()">Save</button>
<button click.delegate="undo()">Undo</button>
<input value.bind="editingItem.firstName" />
<input value.bind="editingItem.lastName" />
</td>
</tr>
</tbody>
</table>
</template>
Clicar no botão editar não faz nada. Curiosamente, se eu adicionar
${isEditing}
Em qualquer lugar do modelo fora de repeat.for, o código funciona conforme o esperado. É como se o mecanismo de renderização não soubesse renderizar novamente os elementos dentro do loop de repetição.
Isso é um inseto? Ou estou fazendo algo bobo?