Commit 50d9ed00 authored by Tae Hoon's avatar Tae Hoon

reset post status form only when reply user is changed

parent aadd36f3
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())
}
}
},
......
<template>
<div
v-if="isOpen"
v-if="isLoggedIn && !resettingForm"
v-show="modalActivated"
class="post-form-modal-view modal-view"
@click="closeModal"
>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment