From 3ecb9d4355fc2234ae46bbddca0e594e2210ca49 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Mon, 6 Jan 2025 12:31:17 -0800 Subject: [PATCH] adding key handling in forms and dialogs for submit and cancel clean up some code --- src/api/forms/components/FormProperties.vue | 11 ++++++ src/api/menu/components/SuperMenu.vue | 34 ++++++++++++++++--- src/api/menu/menu.js | 3 +- .../overlays/components/OverlayComponent.vue | 17 ++++++++++ src/styles/_controls.scss | 4 +-- 5 files changed, 62 insertions(+), 7 deletions(-) diff --git a/src/api/forms/components/FormProperties.vue b/src/api/forms/components/FormProperties.vue index 1e4bdf30bb0..f29370f42eb 100644 --- a/src/api/forms/components/FormProperties.vue +++ b/src/api/forms/components/FormProperties.vue @@ -129,6 +129,7 @@ export default { } }, mounted() { + document.addEventListener('keydown', this.handleKeyDown); this.formSections = this.model.sections.map((section) => { section.id = uuid(); @@ -141,6 +142,9 @@ export default { return section; }); }, + unmounted() { + document.removeEventListener('keydown', this.handleKeyDown); + }, methods: { onChange(data) { this.invalidProperties[data.model.key] = data.invalid; @@ -152,6 +156,13 @@ export default { }, onSave() { this.$emit('on-save'); + }, + handleKeyDown({ key }) { + if (key === 'Enter') { + this.onSave(); + } else if (key === 'Escape') { + this.onCancel(); + } } } }; diff --git a/src/api/menu/components/SuperMenu.vue b/src/api/menu/components/SuperMenu.vue index 4ad7e29e0b8..3b4ddb1cbfd 100644 --- a/src/api/menu/components/SuperMenu.vue +++ b/src/api/menu/components/SuperMenu.vue @@ -27,13 +27,15 @@ :style="styleObject" >
-