diff --git a/scilog/src/app/logbook/widgets/logbook-item/logbook-item.component.spec.ts b/scilog/src/app/logbook/widgets/logbook-item/logbook-item.component.spec.ts index a6df4d0b..78e7a7d4 100644 --- a/scilog/src/app/logbook/widgets/logbook-item/logbook-item.component.spec.ts +++ b/scilog/src/app/logbook/widgets/logbook-item/logbook-item.component.spec.ts @@ -682,4 +682,10 @@ describe('LogbookItemComponent', () => { expect(component.mobile).toEqual(true); }); + it('should open dialog with or without last', () => { + const dialogOpenMock = spyOn(component.dialog, 'open'); + component.openDialog(); + expect(dialogOpenMock.calls.mostRecent().args[1].data['defaultTags']).toEqual(undefined); + }); + }); diff --git a/scilog/src/app/logbook/widgets/logbook-item/logbook-item.component.ts b/scilog/src/app/logbook/widgets/logbook-item/logbook-item.component.ts index af38bd42..e24057da 100644 --- a/scilog/src/app/logbook/widgets/logbook-item/logbook-item.component.ts +++ b/scilog/src/app/logbook/widgets/logbook-item/logbook-item.component.ts @@ -642,7 +642,7 @@ export class LogbookItemComponent implements OnInit { const dialogConfig = new MatDialogConfig(); dialogConfig.autoFocus = true; dialogConfig.disableClose = true; - dialogConfig.data = { "defaultTags": this.childSnippets.last.snippet.tags, "config": this.config } + dialogConfig.data = { "defaultTags": this.childSnippets?.last?.snippet?.tags, "config": this.config } const dialogRef = this.dialog.open(AddContentComponent, dialogConfig); }