diff --git a/lib/content-services/tag/tag-actions.component.ts b/lib/content-services/tag/tag-actions.component.ts index ba059ef80d..9379ba0e25 100644 --- a/lib/content-services/tag/tag-actions.component.ts +++ b/lib/content-services/tag/tag-actions.component.ts @@ -67,15 +67,17 @@ export class TagActionsComponent implements OnChanges { } refreshTag() { - this.tagService.getTagsByNodeId(this.nodeId).subscribe((data) => { - this.tagsEntries = data.list.entries; - this.disableAddTag = false; - this.result.emit(this.tagsEntries); - }, () => { - this.tagsEntries = null; - this.disableAddTag = true; - this.result.emit(this.tagsEntries); - }); + if (this.nodeId) { + this.tagService.getTagsByNodeId(this.nodeId).subscribe((data) => { + this.tagsEntries = data.list.entries; + this.disableAddTag = false; + this.result.emit(this.tagsEntries); + }, () => { + this.tagsEntries = null; + this.disableAddTag = true; + this.result.emit(this.tagsEntries); + }); + } } addTag() { diff --git a/lib/content-services/tag/tag-list.component.spec.ts b/lib/content-services/tag/tag-list.component.spec.ts index 6e929f3da5..a0c7a88aa0 100644 --- a/lib/content-services/tag/tag-list.component.spec.ts +++ b/lib/content-services/tag/tag-list.component.spec.ts @@ -78,8 +78,6 @@ describe('TagList', () => { }); it('Tag list relative a single node should be rendered', (done) => { - component.nodeId = 'fake-node-id'; - component.result.subscribe(() => { fixture.detectChanges(); diff --git a/lib/content-services/tag/tag-node-list.component.ts b/lib/content-services/tag/tag-node-list.component.ts index 9a76bcb782..b218d9b989 100644 --- a/lib/content-services/tag/tag-node-list.component.ts +++ b/lib/content-services/tag/tag-node-list.component.ts @@ -55,10 +55,12 @@ export class TagNodeListComponent implements OnChanges { } refreshTag() { - this.tagService.getTagsByNodeId(this.nodeId).subscribe((data) => { - this.tagsEntries = data.list.entries; - this.results.emit(this.tagsEntries); - }); + if (this.nodeId) { + this.tagService.getTagsByNodeId(this.nodeId).subscribe((data) => { + this.tagsEntries = data.list.entries; + this.results.emit(this.tagsEntries); + }); + } } removeTag(tag: string) {