Skip to content

Commit

Permalink
Fix 'Send test' not reflecting campaign body on first page load
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Oct 17, 2020
1 parent 13aac1a commit 50e488f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions frontend/src/components/Editor.vue
Expand Up @@ -118,6 +118,7 @@ export default {
isPreviewing: false,
isMediaVisible: false,
isEditorFullscreen: false,
isReady: false,
form: {
body: '',
format: this.contentType,
Expand Down Expand Up @@ -195,13 +196,19 @@ export default {
},
onEditorReady() {
this.isReady = true;
// Hack to focus the editor on page load.
this.$nextTick(() => {
window.setTimeout(() => this.$refs.quill.quill.focus(), 100);
});
},
onEditorChange() {
if (!this.isReady) {
return;
}
// The parent's v-model gets { contentType, body }.
this.$emit('input', { contentType: this.form.format, body: this.form.body });
},
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/views/Campaign.vue
Expand Up @@ -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;
Expand Down

0 comments on commit 50e488f

Please sign in to comment.