feat: close modals with esc key (#741)
Co-authored-by: Dominik Pschenitschni <mail@celement.de> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/741 Reviewed-by: konrad <k@knt.li> Co-authored-by: dpschen <dpschen@noreply.kolaente.de> Co-committed-by: dpschen <dpschen@noreply.kolaente.de>
This commit is contained in:
parent
47ad115738
commit
728dfc52e5
4 changed files with 24 additions and 12 deletions
|
@ -1,7 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<transition name="modal">
|
<transition name="modal">
|
||||||
<div class="modal-mask has-overflow" :class="{'has-overflow': overflow}">
|
<div class="modal-mask has-overflow" :class="{'has-overflow': overflow}">
|
||||||
<div class="modal-container" @mousedown.self.prevent.stop="$emit('close')" :class="{'has-overflow': overflow}">
|
<div class="modal-container"
|
||||||
|
@mousedown.self.prevent.stop="$emit('close')"
|
||||||
|
:class="{'has-overflow': overflow}"
|
||||||
|
@shortkey="$emit('close')"
|
||||||
|
v-shortkey="['esc']"
|
||||||
|
>
|
||||||
<div class="modal-content" :class="{'has-overflow': overflow, 'is-wide': wide}">
|
<div class="modal-content" :class="{'has-overflow': overflow, 'is-wide': wide}">
|
||||||
<slot>
|
<slot>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
|
@ -36,14 +41,6 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'modal',
|
name: 'modal',
|
||||||
mounted: function () {
|
|
||||||
document.addEventListener('keydown', (e) => {
|
|
||||||
// Close the model when escape is pressed
|
|
||||||
if (e.keyCode === 27) {
|
|
||||||
this.$emit('close')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
overflow: {
|
overflow: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
<template>
|
<template>
|
||||||
<transition name="fade">
|
<transition name="fade">
|
||||||
<div class="modal-mask hint-modal">
|
<div class="modal-mask hint-modal">
|
||||||
<div @click.self="$router.back()" class="modal-container">
|
<div
|
||||||
|
class="modal-container"
|
||||||
|
@click.self="$router.back()"
|
||||||
|
@shortkey="$router.back()"
|
||||||
|
v-shortkey="['esc']"
|
||||||
|
>
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<card
|
<card
|
||||||
class="has-background-white has-no-shadow"
|
class="has-background-white has-no-shadow"
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="modal-mask hint-modal">
|
<div class="modal-mask hint-modal">
|
||||||
<div @click.self="$router.back()" class="modal-container">
|
<div
|
||||||
|
class="modal-container"
|
||||||
|
@click.self="$router.back()"
|
||||||
|
@shortkey="$router.back()"
|
||||||
|
v-shortkey="['esc']"
|
||||||
|
>
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<card class="has-background-white has-no-shadow" :title="$t('filters.create.title')">
|
<card class="has-background-white has-no-shadow" :title="$t('filters.create.title')">
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="modal-mask">
|
<div class="modal-mask">
|
||||||
<div @mousedown.self="close()" class="modal-container">
|
<div
|
||||||
|
class="modal-container"
|
||||||
|
@mousedown.self="close()"
|
||||||
|
v-shortkey="['esc']"
|
||||||
|
@shortkey="close()"
|
||||||
|
>
|
||||||
<div class="scrolling-content">
|
<div class="scrolling-content">
|
||||||
<a @click="close()" class="close">
|
<a @click="close()" class="close">
|
||||||
<icon icon="times"/>
|
<icon icon="times"/>
|
||||||
|
|
Loading…
Reference in a new issue