Skip to content

Commit c901941

Browse files
committed
Make single-row-builder handle null row instances
1 parent 9a52cbc commit c901941

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

frontend/src/app/features/work-packages/components/wp-fast-table/builders/rows/single-row-builder.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,17 @@ export class SingleRowBuilder {
216216

217217
protected buildEmptyRow(workPackage:WorkPackageResource, row:HTMLTableRowElement):[HTMLTableRowElement, boolean] {
218218
const change = this.workPackageTable.editing.change(workPackage);
219-
const cells:{ [attribute:string]:HTMLTableCellElement } = {};
219+
const cells:Record<string, HTMLTableCellElement> = {};
220220

221221
if (change && !change.isEmpty()) {
222222
// Try to find an old instance of this row
223-
const oldRow = locateTableRowByIdentifier(this.classIdentifier(workPackage))!;
223+
const oldRow = locateTableRowByIdentifier(this.classIdentifier(workPackage));
224224

225225
change.changedAttributes.forEach((attribute:string) => {
226-
cells[attribute] = oldRow.querySelector(`.${tdClassName}.${attribute}`)!;
226+
const oldCell = oldRow?.querySelector<HTMLTableCellElement>(`.${tdClassName}.${attribute}`);
227+
if (oldCell) {
228+
cells[attribute] = oldCell;
229+
}
227230
});
228231
}
229232

0 commit comments

Comments
 (0)