Enter key triggers default button

This commit is contained in:
yeknava
2017-11-26 11:24:58 +03:30
committed by GitHub
parent 5b94192457
commit da52d43a7a

View File

@@ -7,6 +7,7 @@
:adaptive="true"
:clickToClose="clickToClose"
:transition="transition"
@keyup.enter="clickDefault"
@before-open="beforeOpened"
@before-close="beforeClosed"
@opened="$emit('opened', $event)"
@@ -85,6 +86,28 @@
} else {
this.$modal.hide('dialog')
}
},
clickDefault () {
if(this.buttons === undefined || !this.buttons) {
this.$modal.hide('dialog')
}
if(this.buttons.length > 1) {
return this.buttons.map(button => {
if(button.default != undefined && button.default == true) {
if (typeof button.handler === 'function') {
return button.handler()
} else {
this.$modal.hide('dialog')
}
}
});
} else if(this.buttons.length == 1) {
if (typeof this.buttons[0].handler === 'function') {
return this.buttons[0].handler()
} else {
this.$modal.hide('dialog')
}
}
}
}
}