Skip to content

Commit

Permalink
fix (v-edit-dialog): restores save/open/close/cancel events (#3227)
Browse files Browse the repository at this point in the history
* fix (v-edit-dialog): restores **save** event

fixes #3197

* fix(VEditDialog): restored open/close/cancel events
  • Loading branch information
jacekkarczmarczyk authored Jun 11, 2018
1 parent 5f44b8b commit 2da917b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/components/VDataTable/VEditDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export default {

data () {
return {
isActive: false,
isSaving: false
isActive: false
}
},

Expand All @@ -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')
Expand All @@ -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 () {
Expand All @@ -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'
Expand Down

0 comments on commit 2da917b

Please sign in to comment.