chore: Fix position issue and lock scroll
This commit is contained in:
@@ -40,7 +40,7 @@ const menuItems = computed(() => {
|
||||
v-for="item in menuItems"
|
||||
:key="item.value"
|
||||
class="!items-start !gap-1 flex-col cursor-pointer"
|
||||
@click="() => emit('openForward')"
|
||||
@click="event => emit('openForward', event)"
|
||||
>
|
||||
<template #label>
|
||||
<div class="items-start flex gap-1 flex-col">
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
<script setup>
|
||||
import { computed, useTemplateRef, ref, onMounted } from 'vue';
|
||||
import {
|
||||
computed,
|
||||
useTemplateRef,
|
||||
ref,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
reactive,
|
||||
} from 'vue';
|
||||
import { Letter } from 'vue-letter';
|
||||
import { allowedCssProperties } from 'lettersanitizer';
|
||||
import { useScrollLock } from '@vueuse/core';
|
||||
|
||||
import Icon from 'next/icon/Icon.vue';
|
||||
import MessageMenu from 'dashboard/components-next/message/MessageMenu.vue';
|
||||
@@ -26,10 +34,14 @@ const { inbox } = useInbox();
|
||||
const isExpandable = ref(false);
|
||||
const isExpanded = ref(false);
|
||||
const showQuotedMessage = ref(false);
|
||||
const showForwardMessageModal = ref(false);
|
||||
const renderOriginal = ref(false);
|
||||
const contentContainer = useTemplateRef('contentContainer');
|
||||
|
||||
// Forward form
|
||||
const showForwardMessageModal = ref(false);
|
||||
const forwardFormPosition = reactive({ top: 0, right: 0 });
|
||||
const conversationPanelScrollLock = ref(null);
|
||||
|
||||
onMounted(() => {
|
||||
isExpandable.value = contentContainer.value?.scrollHeight > 400;
|
||||
});
|
||||
@@ -104,6 +116,32 @@ const translationKeySuffix = computed(() => {
|
||||
const handleSeeOriginal = () => {
|
||||
renderOriginal.value = !renderOriginal.value;
|
||||
};
|
||||
|
||||
const closeForwardModal = () => {
|
||||
showForwardMessageModal.value = false;
|
||||
if (conversationPanelScrollLock.value)
|
||||
conversationPanelScrollLock.value.value = false;
|
||||
};
|
||||
|
||||
const openForwardModal = event => {
|
||||
// Lock conversation panel scroll
|
||||
// To prevent the conversation from scrolling when the forward form is opened
|
||||
const panel = document.querySelector('.conversation-panel');
|
||||
if (panel) conversationPanelScrollLock.value = useScrollLock(panel, true);
|
||||
// Set position from event
|
||||
if (event?.target) {
|
||||
const buttonRect = event.target.getBoundingClientRect();
|
||||
forwardFormPosition.top = buttonRect.top - 9;
|
||||
forwardFormPosition.right = window.innerWidth - buttonRect.right - 9;
|
||||
}
|
||||
|
||||
showForwardMessageModal.value = true;
|
||||
};
|
||||
|
||||
onUnmounted(() => {
|
||||
if (conversationPanelScrollLock.value)
|
||||
conversationPanelScrollLock.value.value = false;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -127,17 +165,23 @@ const handleSeeOriginal = () => {
|
||||
v-if="showMessageMenu"
|
||||
class="flex gap-2 skip-context-menu flex-shrink-0 items-center relative"
|
||||
>
|
||||
<MessageMenu @open-forward="showForwardMessageModal = true" />
|
||||
<ForwardMessageForm
|
||||
v-if="showForwardMessageModal"
|
||||
:message="contentAttributes?.email"
|
||||
:content="content"
|
||||
:inbox="inbox"
|
||||
:attachments="attachments"
|
||||
:message-id="id"
|
||||
class="absolute right-3 z-50 skip-context-menu top-10"
|
||||
@close="showForwardMessageModal = false"
|
||||
/>
|
||||
<MessageMenu @open-forward="openForwardModal" />
|
||||
<Teleport to="body">
|
||||
<ForwardMessageForm
|
||||
v-if="showForwardMessageModal"
|
||||
:message="contentAttributes?.email"
|
||||
:content="content"
|
||||
:inbox="inbox"
|
||||
:attachments="attachments"
|
||||
:message-id="id"
|
||||
class="fixed z-50 skip-context-menu"
|
||||
:style="{
|
||||
top: `${forwardFormPosition.top}px`,
|
||||
right: `${forwardFormPosition.right}px`,
|
||||
}"
|
||||
@close="closeForwardModal"
|
||||
/>
|
||||
</Teleport>
|
||||
</div>
|
||||
</EmailMeta>
|
||||
</div>
|
||||
|
||||
@@ -34,7 +34,7 @@ const displayFileName = computed(() => {
|
||||
const textColorClass = computed(() => {
|
||||
const colorMap = {
|
||||
'7z': 'dark:text-[#EDEEF0] text-[#2F265F]',
|
||||
csv: 'text-amber-12',
|
||||
csv: 'text-n-amber-12',
|
||||
doc: 'dark:text-[#D6E1FF] text-[#1F2D5C]', // indigo-12
|
||||
docx: 'dark:text-[#D6E1FF] text-[#1F2D5C]', // indigo-12
|
||||
json: 'text-n-slate-12',
|
||||
|
||||
Reference in New Issue
Block a user