+
project.value?.permissions.canCreateSavedView
diff --git a/packages/frontend-2/lib/common/composables/dom.ts b/packages/frontend-2/lib/common/composables/dom.ts
index 60edcc27e..f7c829371 100644
--- a/packages/frontend-2/lib/common/composables/dom.ts
+++ b/packages/frontend-2/lib/common/composables/dom.ts
@@ -1,6 +1,7 @@
import { TIME_MS, timeoutAt } from '@speckle/shared'
-import { until } from '@vueuse/core'
+import { until, useScroll } from '@vueuse/core'
import DOMPurify from 'dompurify'
+import type { ShallowRef } from 'vue'
const purify = async (source: string) => {
let purify: DOMPurify.DOMPurifyI
@@ -55,3 +56,26 @@ export function usePurifiedHtml(
purifiedHtml: computed(() => asyncData.data.value || '')
}
}
+
+/**
+ * KeepAlive loses scroll position - use this to cache and restore the position
+ * upon reactivation
+ */
+export const useKeepAliveScrollState = (el: ShallowRef) => {
+ const scrollTracker = useScroll(el, {
+ throttle: 100
+ })
+
+ const retainedX = ref(scrollTracker.x.value)
+ const retainedY = ref(scrollTracker.y.value)
+
+ onDeactivated(() => {
+ retainedX.value = scrollTracker.x.value
+ retainedY.value = scrollTracker.y.value
+ })
+
+ onActivated(() => {
+ scrollTracker.x.value = retainedX.value
+ scrollTracker.y.value = retainedY.value
+ })
+}