diff --git a/frontend/src/ContactPanel.vue b/frontend/src/ContactPanel.vue index 7bcb020..927eca3 100644 --- a/frontend/src/ContactPanel.vue +++ b/frontend/src/ContactPanel.vue @@ -3,7 +3,7 @@ // socket (via the bridge pagerite.js hands to contact-main), with the // composer shared with the admin inbox. state is contact-main's reactive // store ({open, thread, unread}). -import { computed, nextTick, reactive, ref, watch } from 'vue' +import { computed, nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue' import { formatWhen } from './analytics/format.js' import Composer from './Composer.vue' @@ -26,6 +26,13 @@ watch(() => props.state.open, (open) => { if (open) scrollDown() }) // Relative timestamps like in analytics. const fmtTime = (t) => formatWhen(t) +// Escape closes, like the paskia dialogs whose backdrop we share. +function onKey(ev) { + if (ev.key === 'Escape' && props.state.open) emit('close') +} +onMounted(() => addEventListener('keydown', onKey)) +onUnmounted(() => removeEventListener('keydown', onKey)) + const NAME_KEY = 'pagerite-contact-name' const EMAIL_KEY = 'pagerite-contact-email' @@ -53,7 +60,7 @@ function onSend(md) {