diff --git a/lib/core/datatable/components/datatable-cell/datatable-cell.component.spec.ts b/lib/core/datatable/components/datatable-cell/datatable-cell.component.spec.ts index 11a2eddba6..d048b56be0 100644 --- a/lib/core/datatable/components/datatable-cell/datatable-cell.component.spec.ts +++ b/lib/core/datatable/components/datatable-cell/datatable-cell.component.spec.ts @@ -115,4 +115,50 @@ describe('DataTableCellComponent', () => { expect(component.row['node'].entry.name).not.toBe('updated-name'); expect(component.row['cache'].name).not.toBe('updated-name'); }); + + it('not should throw error if key not found', () => { + const component = new DateCellComponent( + null, + alfrescoApiService, + new AppConfigService(null) + ); + + component.column = { + key: 'contentSize.sizeInBytes', + type: 'text' + }; + + component.row = { + cache: { + name: 'some-name' + }, + node: { + entry: { + id: 'id', + name: 'some-name', + contentSize: { + sizeInBytes: '12Mb' + } + } + } + }; + + component.ngOnInit(); + + alfrescoApiService.nodeUpdated.next({ + id: 'id', + contentSize: { sizeInBytes: '11Mb' } + } as any); + + expect(component.row['node'].entry.contentSize.sizeInBytes).toBe('11Mb'); + expect(component.row['cache']['contentSize.sizeInBytes']).toBe('11Mb'); + + alfrescoApiService.nodeUpdated.next({ + id: 'id', + name: 'updated-name' + } as any); + + expect(component.row['node'].entry.name).toBe('updated-name'); + expect(component.row['cache']['contentSize.sizeInBytes']).toBe(''); + }); }); diff --git a/lib/core/datatable/components/datatable-cell/datatable-cell.component.ts b/lib/core/datatable/components/datatable-cell/datatable-cell.component.ts index 819362e631..266d204f7a 100644 --- a/lib/core/datatable/components/datatable-cell/datatable-cell.component.ts +++ b/lib/core/datatable/components/datatable-cell/datatable-cell.component.ts @@ -93,7 +93,7 @@ export class DataTableCellComponent implements OnInit, OnDestroy { if (this.row) { if (this.row['node'].entry.id === node.id) { this.row['node'].entry = node; - this.row['cache'][this.column.key] = this.column.key.split('.').reduce((source, key) => source[key], node); + this.row['cache'][this.column.key] = this.column.key.split('.').reduce((source, key) => source ? source[key] : '', node); this.updateValue(); } }