fix: allow scroll to comment if hash is present

This commit is contained in:
Shariq Ansari 2024-01-29 22:51:11 +05:30
parent 8a5b5a6e0f
commit f4be8cc259

View File

@ -769,6 +769,7 @@ import {
} from 'frappe-ui'
import { useElementVisibility } from '@vueuse/core'
import { ref, computed, h, defineModel, markRaw, watch, nextTick } from 'vue'
import { useRoute } from 'vue-router'
const { makeCall } = globalStore()
const { getUser } = usersStore()
@ -1110,11 +1111,14 @@ watch([reload, reload_email], ([reload_value, reload_email_value]) => {
}
})
function scroll(el) {
function scroll(hash) {
setTimeout(() => {
if (!el) {
let el
if (!hash) {
let e = document.getElementsByClassName('activity')
el = e[e.length - 1]
} else {
el = document.getElementById(hash)
}
if (el && !useElementVisibility(el).value) {
el.scrollIntoView({ behavior: 'smooth' })
@ -1125,7 +1129,12 @@ function scroll(el) {
defineExpose({ emailBox })
nextTick(() => scroll())
const route = useRoute()
nextTick(() => {
const hash = route.hash.slice(1) || null
scroll(hash)
})
</script>
<style scoped>