From cb5791ee96335e71567b3ae4a103885bb16b2797 Mon Sep 17 00:00:00 2001
From: Paul Elliott <paul.elliott@kitware.com>
Date: Fri, 15 Dec 2023 11:55:07 -0500
Subject: [PATCH] feat(Save Dialogs): enter key triggers save

---
 src/components/SaveSegmentGroupDialog.vue | 7 ++++++-
 src/components/SaveSession.vue            | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/components/SaveSegmentGroupDialog.vue b/src/components/SaveSegmentGroupDialog.vue
index 579a6e97..f064e121 100644
--- a/src/components/SaveSegmentGroupDialog.vue
+++ b/src/components/SaveSegmentGroupDialog.vue
@@ -43,6 +43,7 @@ import { onMounted, ref } from 'vue';
 import { saveAs } from 'file-saver';
 import { useSegmentGroupStore } from '@/src/store/segmentGroups';
 import { writeImage } from '@/src/io/readWriteImage';
+import { onKeyDown } from '@vueuse/core';
 
 const EXTENSIONS = [
   'dcm',
@@ -57,7 +58,7 @@ const EXTENSIONS = [
 ];
 
 const props = defineProps<{
-  close: () => undefined;
+  close: () => void;
   id: string;
 }>();
 const fileName = ref('');
@@ -87,6 +88,10 @@ onMounted(() => {
   fileName.value = segmentGroupStore.metadataByID[props.id].name;
 });
 
+onKeyDown('Enter', () => {
+  saveSegmentGroup();
+});
+
 function validFileName(name: string) {
   return name.trim().length > 0 || 'Required';
 }
diff --git a/src/components/SaveSession.vue b/src/components/SaveSession.vue
index ad2710b3..33c1973d 100644
--- a/src/components/SaveSession.vue
+++ b/src/components/SaveSession.vue
@@ -33,6 +33,7 @@
 <script lang="ts">
 import { defineComponent, onMounted, ref } from 'vue';
 import { saveAs } from 'file-saver';
+import { onKeyDown } from '@vueuse/core';
 
 import { serialize } from '../io/state-file';
 
@@ -68,6 +69,10 @@ export default defineComponent({
       fileName.value = DEFAULT_FILENAME;
     });
 
+    onKeyDown('Enter', () => {
+      saveSession();
+    });
+
     function validFileName(name: string) {
       return name.trim().length > 0 || 'Required';
     }