diff options
| author | taehoon <th.dev91@gmail.com> | 2019-09-28 16:35:39 -0400 |
|---|---|---|
| committer | taehoon <th.dev91@gmail.com> | 2019-09-28 16:35:39 -0400 |
| commit | 50d9ed00078e400ccd0ddc2ca38044c1fe70c1db (patch) | |
| tree | d5e5e8b36c0288d84efc7b99488b125a9e2f2c26 /src/components/post_status_modal/post_status_modal.js | |
| parent | aadd36f3ec2d5131deae43a4e8042455a90ca16f (diff) | |
reset post status form only when reply user is changed
Diffstat (limited to 'src/components/post_status_modal/post_status_modal.js')
| -rw-r--r-- | src/components/post_status_modal/post_status_modal.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/components/post_status_modal/post_status_modal.js b/src/components/post_status_modal/post_status_modal.js index 1033ba11..38258296 100644 --- a/src/components/post_status_modal/post_status_modal.js +++ b/src/components/post_status_modal/post_status_modal.js @@ -1,24 +1,41 @@ import PostStatusForm from '../post_status_form/post_status_form.vue' +import get from 'lodash/get' const PostStatusModal = { components: { PostStatusForm }, + data () { + return { + resettingForm: false + } + }, computed: { isLoggedIn () { return !!this.$store.state.users.currentUser }, - isOpen () { - return this.isLoggedIn && this.$store.state.postStatus.modalActivated + modalActivated () { + return this.$store.state.postStatus.modalActivated + }, + isFormVisible () { + return this.isLoggedIn && !this.resettingForm && this.modalActivated }, params () { return this.$store.state.postStatus.params || {} } }, watch: { - isOpen (val) { + params (newVal, oldVal) { + if (get(newVal, 'repliedUser.id') !== get(oldVal, 'repliedUser.id')) { + this.resettingForm = true + this.$nextTick(() => { + this.resettingForm = false + }) + } + }, + isFormVisible (val) { if (val) { - this.$nextTick(() => this.$el.querySelector('textarea').focus()) + this.$nextTick(() => this.$el && this.$el.querySelector('textarea').focus()) } } }, |
