From 2da917b65a26348df057a8720de545b02f43cb42 Mon Sep 17 00:00:00 2001 From: Jacek Karczmarczyk Date: Tue, 12 Jun 2018 00:52:40 +0700 Subject: [PATCH] fix (v-edit-dialog): restores save/open/close/cancel events (#3227) * fix (v-edit-dialog): restores **save** event fixes #3197 * fix(VEditDialog): restored open/close/cancel events --- src/components/VDataTable/VEditDialog.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/components/VDataTable/VEditDialog.js b/src/components/VDataTable/VEditDialog.js index 35f9e30917d..09df0f9d9f7 100644 --- a/src/components/VDataTable/VEditDialog.js +++ b/src/components/VDataTable/VEditDialog.js @@ -16,8 +16,7 @@ export default { data () { return { - isActive: false, - isSaving: false + isActive: false } }, @@ -39,13 +38,19 @@ export default { watch: { isActive (val) { - val && setTimeout(this.focus, 50) // Give DOM time to paint + if (val) { + this.$emit('open') + setTimeout(this.focus, 50) // Give DOM time to paint + } else { + this.$emit('close') + } } }, methods: { cancel () { this.isActive = false + this.$emit('cancel') }, focus () { const input = this.$refs.content.querySelector('input') @@ -66,7 +71,10 @@ export default { 'class': 'v-small-dialog__actions' }, [ this.genButton(this.cancel, this.cancelText), - this.genButton(() => this.save(this.returnValue), this.saveText) + this.genButton(() => { + this.save(this.returnValue) + this.$emit('save') + }, this.saveText) ]) }, genContent () { @@ -75,7 +83,10 @@ export default { keydown: e => { const input = this.$refs.content.querySelector('input') e.keyCode === keyCodes.esc && this.cancel() - e.keyCode === keyCodes.enter && input && this.save(input.value) + if (e.keyCode === keyCodes.enter && input) { + this.save(input.value) + this.$emit('save') + } } }, ref: 'content'