Etemplate: Update controller indexMap when adding a new row

Fixes deleting former top mail that got moved down by a pushed new mail removed both newly added and the selected mail
This commit is contained in:
nathangray
2020-07-29 13:20:01 -06:00
parent 33d983f547
commit 471741ce12
2 changed files with 22 additions and 0 deletions

View File

@ -458,6 +458,18 @@ export class et2_dataview_controller
this._grid.insertRow(_entry.idx, _entry.row);
}
// Update index map
if(this._indexMap[_entry.idx].uid !== _entry.uid)
{
let max = parseInt(Object.keys(this._indexMap).reduce((a, b) => this._indexMap[a] > this._indexMap[b] ? a : b));
for(let idx = max; idx >= _entry.idx; idx--)
{
this._indexMap[idx].idx = idx+1;
this._indexMap[this._indexMap[idx].idx] = this._indexMap[idx];
}
this._indexMap[_entry.idx] = _entry
}
return this.hasData;
}