fix: scroll on load and after reply
This commit is contained in:
parent
fd354276ae
commit
f99abd0330
@ -26,8 +26,11 @@
|
|||||||
<span>New Task</span>
|
<span>New Task</span>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="activities?.length" class="flex-1 overflow-y-auto">
|
<div v-if="activities?.length" class="activities flex-1 overflow-y-auto">
|
||||||
<div v-if="title == 'Notes'" class="grid grid-cols-3 gap-4 px-10 pb-5">
|
<div
|
||||||
|
v-if="title == 'Notes'"
|
||||||
|
class="activity grid grid-cols-3 gap-4 px-10 pb-5"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
v-for="note in activities"
|
v-for="note in activities"
|
||||||
class="group flex h-48 cursor-pointer flex-col justify-between gap-2 rounded-md bg-gray-50 px-4 py-3 hover:bg-gray-100"
|
class="group flex h-48 cursor-pointer flex-col justify-between gap-2 rounded-md bg-gray-50 px-4 py-3 hover:bg-gray-100"
|
||||||
@ -77,7 +80,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="title == 'Tasks'" class="px-10 pb-5">
|
<div v-else-if="title == 'Tasks'" class="activity px-10 pb-5">
|
||||||
<div v-for="(task, i) in activities">
|
<div v-for="(task, i) in activities">
|
||||||
<div
|
<div
|
||||||
class="flex cursor-pointer gap-6 rounded p-2.5 duration-300 ease-in-out hover:bg-gray-50"
|
class="flex cursor-pointer gap-6 rounded p-2.5 duration-300 ease-in-out hover:bg-gray-50"
|
||||||
@ -164,7 +167,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="title == 'Calls'">
|
<div v-else-if="title == 'Calls'" class="activity">
|
||||||
<div v-for="(call, i) in activities">
|
<div v-for="(call, i) in activities">
|
||||||
<div class="grid grid-cols-[30px_minmax(auto,_1fr)] gap-4 px-10">
|
<div class="grid grid-cols-[30px_minmax(auto,_1fr)] gap-4 px-10">
|
||||||
<div
|
<div
|
||||||
@ -262,7 +265,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else v-for="(activity, i) in activities">
|
<div v-else v-for="(activity, i) in activities" class="activity">
|
||||||
<div class="grid grid-cols-[30px_minmax(auto,_1fr)] gap-4 px-10">
|
<div class="grid grid-cols-[30px_minmax(auto,_1fr)] gap-4 px-10">
|
||||||
<div
|
<div
|
||||||
class="relative flex justify-center before:absolute before:left-[50%] before:top-0 before:-z-10 before:border-l before:border-gray-200"
|
class="relative flex justify-center before:absolute before:left-[50%] before:top-0 before:-z-10 before:border-l before:border-gray-200"
|
||||||
@ -585,6 +588,7 @@
|
|||||||
v-if="['Emails', 'Activity'].includes(title)"
|
v-if="['Emails', 'Activity'].includes(title)"
|
||||||
v-model="doc"
|
v-model="doc"
|
||||||
v-model:reload="reload_email"
|
v-model:reload="reload_email"
|
||||||
|
@scroll="scroll"
|
||||||
/>
|
/>
|
||||||
<NoteModal
|
<NoteModal
|
||||||
v-model="showNoteModal"
|
v-model="showNoteModal"
|
||||||
@ -643,16 +647,8 @@ import {
|
|||||||
createListResource,
|
createListResource,
|
||||||
call,
|
call,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import {
|
import { useElementVisibility } from '@vueuse/core'
|
||||||
ref,
|
import { ref, computed, h, defineModel, markRaw, watch, nextTick } from 'vue'
|
||||||
computed,
|
|
||||||
h,
|
|
||||||
defineModel,
|
|
||||||
markRaw,
|
|
||||||
watch,
|
|
||||||
onMounted,
|
|
||||||
nextTick,
|
|
||||||
} from 'vue'
|
|
||||||
|
|
||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
const { getContact } = contactsStore()
|
const { getContact } = contactsStore()
|
||||||
@ -965,6 +961,21 @@ watch([reload, reload_email], ([reload_value, reload_email_value]) => {
|
|||||||
reload_email.value = false
|
reload_email.value = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function scroll(el) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!el) {
|
||||||
|
let e = document.getElementsByClassName('activity')
|
||||||
|
el = e[e.length - 1]
|
||||||
|
}
|
||||||
|
if (!useElementVisibility(el).value) {
|
||||||
|
el.scrollIntoView({ behavior: 'smooth' })
|
||||||
|
el.focus()
|
||||||
|
}
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
|
||||||
|
nextTick(() => scroll())
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@ -54,6 +54,8 @@ import { ref, watch, computed, defineModel } from 'vue'
|
|||||||
const doc = defineModel()
|
const doc = defineModel()
|
||||||
const reload = defineModel('reload')
|
const reload = defineModel('reload')
|
||||||
|
|
||||||
|
const emit = defineEmits(['scroll'])
|
||||||
|
|
||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
|
|
||||||
const showCommunicationBox = ref(false)
|
const showCommunicationBox = ref(false)
|
||||||
@ -104,6 +106,7 @@ async function submitComment() {
|
|||||||
await sendMail()
|
await sendMail()
|
||||||
newEmail.value = ''
|
newEmail.value = ''
|
||||||
reload.value = true
|
reload.value = true
|
||||||
|
emit('scroll')
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({ show: showCommunicationBox, editor: newEmailEditor })
|
defineExpose({ show: showCommunicationBox, editor: newEmailEditor })
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user