Make dialog closable using esc key

This commit is contained in:
Radhi Fadlillah 2019-08-07 17:38:53 +07:00
parent dcef9162e4
commit 690bda85f7
3 changed files with 17 additions and 7 deletions

View file

@ -1,5 +1,5 @@
var template = `
<div v-if="visible" class="custom-dialog-overlay">
<div v-if="visible" class="custom-dialog-overlay" @keyup.esc="handleEscPressed">
<div class="custom-dialog">
<p class="custom-dialog-header">{{title}}</p>
<div class="custom-dialog-body">
@ -89,6 +89,10 @@ export default {
secondClick: {
type: Function,
default () { this.visible = false; }
},
escPressed: {
type: Function,
default () { this.visible = false; }
}
},
data() {
@ -156,6 +160,9 @@ export default {
handleSecondClick() {
this.secondClick();
},
handleEscPressed() {
this.escPressed();
},
handleInput(index) {
// Create initial variable
var field = this.formFields[index],

View file

@ -33,6 +33,9 @@ export default {
},
secondClick: () => {
this.dialog.visible = false;
},
escPressed: () => {
if (!this.loading) this.dialog.visible = false;
}
}
},

File diff suppressed because one or more lines are too long