Skip to content

armgit / posta

Public Imported from GitHub
0

Self-hosted email delivery platform that enables applications to send emails via HTTP APIs while handling SMTP delivery, templates, storage, security, and analytics. Fully self-hostable alternative to services like SendGrid or Mailgun.

feat(ui): add Escape key (close) support to useModalSafeClose

Jude mpoyo0d8ab5389cfd
diff --git a/web/src/composables/useModalSafeClose.ts b/web/src/composables/useModalSafeClose.ts
index 2bf218a..f65c058 100644
--- a/web/src/composables/useModalSafeClose.ts
+++ b/web/src/composables/useModalSafeClose.ts
@@ -1,4 +1,4 @@
-import { ref } from 'vue';
+import { ref, onMounted, onUnmounted } from 'vue';
export function useModalSafeClose(closeAction: () => void) {
const isClickStartingOnOverlay = ref(false);
@@ -16,6 +16,17 @@ export function useModalSafeClose(closeAction: () => void) {
isClickStartingOnOverlay.value = false;
};
+ const handleKeyDown = (event: KeyboardEvent): void => {
+ if (event.key === 'Escape') {
+ closeAction();
+ }
+ };
+ onMounted(() => {
+ document.addEventListener('keydown', handleKeyDown);
+ });
+ onUnmounted(() => {
+ document.removeEventListener('keydown', handleKeyDown);
+ });
return {
watchClickStart,
confirmClickEnd