diff --git a/static/js/directives/ui/markdown/markdown-view.component.ts b/static/js/directives/ui/markdown/markdown-view.component.ts index d6045af03..3ba698942 100644 --- a/static/js/directives/ui/markdown/markdown-view.component.ts +++ b/static/js/directives/ui/markdown/markdown-view.component.ts @@ -30,7 +30,7 @@ export class MarkdownViewComponent implements OnChanges { if (changes['content']) { if (!changes['content'].currentValue && this.placeholderNeeded) { this.convertedHTML = this.$sce.trustAsHtml(this.placeholder); - } else if (this.firstLineOnly) { + } else if (this.firstLineOnly && changes['content'].currentValue) { const firstLine: string = changes['content'].currentValue.split('\n') // Skip code lines .filter(line => line.indexOf(' ') != 0) @@ -41,9 +41,8 @@ export class MarkdownViewComponent implements OnChanges { this.convertedHTML = this.$sanitize(this.markdownConverter.makeHtml(firstLine)); } else { - this.convertedHTML = this.$sanitize(this.markdownConverter.makeHtml(changes['content'].currentValue)); + this.convertedHTML = this.$sanitize(this.markdownConverter.makeHtml(changes['content'].currentValue || '')); } - } } }