From 50e488fc01834edaec47b84797a183fe7af1d8d5 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sat, 17 Oct 2020 23:38:29 +0530 Subject: [PATCH] Fix 'Send test' not reflecting campaign body on first page load --- frontend/src/components/Editor.vue | 7 +++++++ frontend/src/views/Campaign.vue | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Editor.vue b/frontend/src/components/Editor.vue index 43a8cf0..2ef8262 100644 --- a/frontend/src/components/Editor.vue +++ b/frontend/src/components/Editor.vue @@ -118,6 +118,7 @@ export default { isPreviewing: false, isMediaVisible: false, isEditorFullscreen: false, + isReady: false, form: { body: '', format: this.contentType, @@ -195,6 +196,8 @@ export default { }, onEditorReady() { + this.isReady = true; + // Hack to focus the editor on page load. this.$nextTick(() => { window.setTimeout(() => this.$refs.quill.quill.focus(), 100); @@ -202,6 +205,10 @@ export default { }, onEditorChange() { + if (!this.isReady) { + return; + } + // The parent's v-model gets { contentType, body }. this.$emit('input', { contentType: this.form.format, body: this.form.body }); }, diff --git a/frontend/src/views/Campaign.vue b/frontend/src/views/Campaign.vue index 2d3bf1d..ba5ac22 100644 --- a/frontend/src/views/Campaign.vue +++ b/frontend/src/views/Campaign.vue @@ -198,7 +198,13 @@ export default Vue.extend({ getCampaign(id) { return this.$api.getCampaign(id).then((data) => { this.data = data; - this.form = { ...this.form, ...data }; + this.form = { + ...this.form, + ...data, + + // The structure that is populated by editor input event. + content: { contentType: data.contentType, body: data.body }, + }; if (data.sendAt !== null) { this.form.sendLater = true;