Fix edit field render bug(CommentForm)

- remove no-ssr, which was not necessary and causing the edit field not to appear the majority of the times visiting a Post.
- this was really bad user experience since a user would need to refresh the page to comment.
- removed args in refetchPostComments as there are no params passed in when it is called anymore
- needed to add an if statement since if there are no comments on a Post, then this.$apollo.queries.Post is undefined and it errors out trying to call refetch()
- update test to remove no-ssr

Co-authored-by: Mike Aono <aonomike@gmail.com>
This commit is contained in:
Matt Rider 2019-05-27 17:02:00 -03:00
parent 7879dad940
commit b378bcb286
3 changed files with 13 additions and 15 deletions

View File

@ -5,14 +5,12 @@
> >
<template slot-scope="{ errors }"> <template slot-scope="{ errors }">
<ds-card> <ds-card>
<no-ssr> <hc-editor
<hc-editor ref="editor"
ref="editor" :users="users"
:users="users" :value="form.content"
:value="form.content" @input="updateEditorContent"
@input="updateEditorContent" />
/>
</no-ssr>
<ds-space /> <ds-space />
<ds-flex :gutter="{ base: 'small', md: 'small', sm: 'x-large', xs: 'x-large' }"> <ds-flex :gutter="{ base: 'small', md: 'small', sm: 'x-large', xs: 'x-large' }">
<ds-flex-item :width="{ base: '0%', md: '50%', sm: '0%', xs: '0%' }" /> <ds-flex-item :width="{ base: '0%', md: '50%', sm: '0%', xs: '0%' }" />

View File

@ -1,4 +1,4 @@
import { config, mount, createLocalVue, createWrapper } from '@vue/test-utils' import { mount, createLocalVue, createWrapper } from '@vue/test-utils'
import CommentForm from './index.vue' import CommentForm from './index.vue'
import Styleguide from '@human-connection/styleguide' import Styleguide from '@human-connection/styleguide'
@ -6,8 +6,6 @@ const localVue = createLocalVue()
localVue.use(Styleguide) localVue.use(Styleguide)
config.stubs['no-ssr'] = '<span><slot /></span>'
describe('CommentForm.vue', () => { describe('CommentForm.vue', () => {
let mocks let mocks
let wrapper let wrapper

View File

@ -54,13 +54,15 @@ export default {
}, },
}, },
mounted() { mounted() {
this.$root.$on('refetchPostComments', comment => { this.$root.$on('refetchPostComments', () => {
this.refetchPostComments(comment) this.refetchPostComments()
}) })
}, },
methods: { methods: {
refetchPostComments(comment) { refetchPostComments() {
this.$apollo.queries.Post.refetch() if (this.$apollo.queries.Post) {
this.$apollo.queries.Post.refetch()
}
}, },
}, },
apollo: { apollo: {