vue-bulma / modal

Modal component for Vue Bulma
MIT License
49 stars 28 forks source link

Dialog box may be closed after route is changed #14

Closed gitpaladin closed 6 years ago

gitpaladin commented 7 years ago

When user goes back, the parent component may be destroyed. So the modal dialog should be closed rather remaining on the top.

moonlik commented 7 years ago

Have the same problem. @gitpaladin did you solve this?

@fundon @luventa @netpi any suggestions?

octavius37 commented 5 years ago

For anyone wondering how to approach this. As far as I can gather, the component is destroyed when the parent component is destroyed, however, because the modal appends its element to the document it has to manually remove the element on destroy. This is what I added to BaseModal.vue `data() { return { show: this.visible } },

destroyed() { this.$emit('close') try { document.body.removeChild(this.$el) } catch (e) {

}

},

mounted() { document.body.appendChild(this.$el) },` I added the try because the element is not necessarily a child of the document I found, could be handled differently. I don't know if this is still being maintained but could make a pull request?

edit: sorry for the formatting the code highlight is not working for me or something