From 6a94b53934842cc8dc9a8a54fd112e88d4123547 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 2 Jun 2022 14:33:23 +0530 Subject: [PATCH] enhancement: hide slider on escape key Signed-off-by: Pranav C --- packages/nc-gui/components/global/NcSlider.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/global/NcSlider.vue b/packages/nc-gui/components/global/NcSlider.vue index bcd0acccdd..3ef4254864 100644 --- a/packages/nc-gui/components/global/NcSlider.vue +++ b/packages/nc-gui/components/global/NcSlider.vue @@ -26,9 +26,22 @@ export default { mounted() { (document.querySelector('[data-app]') || this.$root.$el).append(this.$el) }, - destroyed() { this.$el.parentNode && this.$el.parentNode.removeChild(this.$el) + }, + created() { + document.body.addEventListener('keyup', this.onKeyup, true) + }, + beforeDestroy() { + document.body.removeEventListener('keyup', this.onKeyup, true) + }, + + methods: { + onKeyup(e) { + if (e.key === 'Escape') { + this.modal = false + } + } } }