fix: close notification panel if click outside
This commit is contained in:
parent
b3a86ab672
commit
ee66df3827
@ -9,6 +9,7 @@
|
|||||||
<div class="flex-1 overflow-y-auto">
|
<div class="flex-1 overflow-y-auto">
|
||||||
<div class="mb-3 flex flex-col">
|
<div class="mb-3 flex flex-col">
|
||||||
<SidebarLink
|
<SidebarLink
|
||||||
|
id="notifications-btn"
|
||||||
label="Notifications"
|
label="Notifications"
|
||||||
:icon="NotificationsIcon"
|
:icon="NotificationsIcon"
|
||||||
:isCollapsed="isSidebarCollapsed"
|
:isCollapsed="isSidebarCollapsed"
|
||||||
|
|||||||
@ -72,11 +72,24 @@ import UserAvatar from '@/components/UserAvatar.vue'
|
|||||||
import { notificationsStore } from '@/stores/notifications'
|
import { notificationsStore } from '@/stores/notifications'
|
||||||
import { globalStore } from '@/stores/global'
|
import { globalStore } from '@/stores/global'
|
||||||
import { timeAgo } from '@/utils'
|
import { timeAgo } from '@/utils'
|
||||||
import { computed } from 'vue'
|
import { onClickOutside } from '@vueuse/core'
|
||||||
import { FeatherIcon } from 'frappe-ui'
|
import { ref, computed } from 'vue'
|
||||||
|
|
||||||
const isSidebarCollapsed = computed(() => globalStore().isSidebarCollapsed)
|
const isSidebarCollapsed = computed(() => globalStore().isSidebarCollapsed)
|
||||||
|
|
||||||
|
const target = ref(null)
|
||||||
|
onClickOutside(
|
||||||
|
target,
|
||||||
|
() => {
|
||||||
|
if (notificationsStore().visible) {
|
||||||
|
toggleNotificationPanel()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ignore: ['#notifications-btn'],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
function toggleNotificationPanel() {
|
function toggleNotificationPanel() {
|
||||||
notificationsStore().toggle()
|
notificationsStore().toggle()
|
||||||
}
|
}
|
||||||
@ -97,7 +110,7 @@ function getRoute(notification) {
|
|||||||
return {
|
return {
|
||||||
name: notification.route_name,
|
name: notification.route_name,
|
||||||
params: params,
|
params: params,
|
||||||
hash: "#" + notification.comment,
|
hash: '#' + notification.comment,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user