I have an ordered table with a field on one entity which you can change to "re-rank" that row on the table:
<table>
<thead>
<th>Rank</th>
<th>Name</th>
</thead>
<tbody>
<tr *ngFor="let entity of entities">
<td>
<input *ngIf='entity === currentEntity'
value="{{entity.Rank}}"
type="number"
min="1"
max="{{entities.length}}"
(change)="updateRank(entity, $event)">
<span *ngIf='entity !== currentEntity'>{{entity.Rank}}</span>
</td>
<td>
<span>{{entity.Name}}</span>
</td>
</tr>
</tbody>
</table>
So the number input is only for the current entity, and on a change, I re-rank these in the back-end and update the ordering on the UI.
This works great, but the issue is that when you are using the arrow keys to change the rank, the focus is only preserved when decreasing the rank. When you increase the rank, the focus is removed from the input box.
JsFiddle: https://jsfiddle.net/JustinDao/t0hwLu4b/ (try on Chrome or Firefox)
I think this is due to how Angular creates the DOM elements, but I'm not entirely sure. Is there a way for me to preserve the focus when increasing the rank as well?