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 useSafeModalClose to distinguish intent from accidental clicks

Jude mpoyod95e5c66843a
diff --git a/web/src/composables/useModalSafeClose.ts b/web/src/composables/useModalSafeClose.ts
new file mode 100644
index 0000000..2bf218a
--- /dev/null
+++ b/web/src/composables/useModalSafeClose.ts
@@ -0,0 +1,23 @@
+import { ref } from 'vue';
+export function useModalSafeClose(closeAction: () => void) {
+ const isClickStartingOnOverlay = ref(false);
+
+ const watchClickStart = (event: MouseEvent): void => {
+ isClickStartingOnOverlay.value = event.target === event.currentTarget;
+ };
+
+ const confirmClickEnd = (event: MouseEvent): void => {
+ const isClickEndingOnOverlay = event.target === event.currentTarget;
+
+ if (isClickStartingOnOverlay.value && isClickEndingOnOverlay) {
+ closeAction();
+ }
+
+ isClickStartingOnOverlay.value = false;
+ };
+
+ return {
+ watchClickStart,
+ confirmClickEnd
+ };
+}
\ No newline at end of file