From 94a5a6c4c0d8b7a4b289dfee75bc4b0a2bd257d9 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 3 Apr 2021 12:08:46 +0200 Subject: [PATCH] web/elements: fix race condition in codemirror Signed-off-by: Jens Langhammer --- web/src/elements/CodeMirror.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/src/elements/CodeMirror.ts b/web/src/elements/CodeMirror.ts index 6d1c7381b..3f8d397b3 100644 --- a/web/src/elements/CodeMirror.ts +++ b/web/src/elements/CodeMirror.ts @@ -24,11 +24,15 @@ export class CodeMirrorTextarea extends LitElement { editor?: CodeMirror.EditorFromTextArea; + _value?: string; + @property() set value(v: string) { if (v === null) return; if (this.editor) { this.editor.setValue(v); + } else { + this._value = v; } } @@ -70,6 +74,7 @@ export class CodeMirrorTextarea extends LitElement { readOnly: this.readOnly, autoRefresh: true, lineWrapping: true, + value: this._value }); this.editor.on("blur", () => { this.editor?.save(); @@ -77,6 +82,6 @@ export class CodeMirrorTextarea extends LitElement { } render(): TemplateResult { - return html``; + return html``; } }