mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
fix(ux): add Escape listener on Modal
This commit is contained in:
parent
90c8516e62
commit
795df3e8b9
@ -25,14 +25,38 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
openModal: {
|
||||
default: false,
|
||||
type: Boolean,
|
||||
},
|
||||
setCloseListener: {
|
||||
default: true,
|
||||
type: Boolean,
|
||||
},
|
||||
},
|
||||
emits: ['closemodal'],
|
||||
};
|
||||
watch: {
|
||||
openModal(value: boolean) {
|
||||
if (value) {
|
||||
document.addEventListener('keyup', this.escapeEventListener);
|
||||
} else {
|
||||
document.removeEventListener('keyup', this.escapeEventListener);
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
escapeEventListener(event: KeyboardEvent) {
|
||||
if (event.code !== 'Escape') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$emit('closemodal');
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
@ -11,7 +11,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Search Modal -->
|
||||
<Modal :open-modal="openModal" @closemodal="close">
|
||||
<Modal :open-modal="openModal" @closemodal="close" :set-close-listener="false">
|
||||
<!-- Search Input -->
|
||||
<div class="p-1">
|
||||
<input
|
||||
|
Loading…
Reference in New Issue
Block a user