Skip to content

📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

fix: update element references for scroll event handling in TOC component

Smaug6739d32330fc5497
diff --git a/frontend/app/App.vue b/frontend/app/App.vue
index b4a49cf8..27ab3c13 100644
--- a/frontend/app/App.vue
+++ b/frontend/app/App.vue
@@ -1,5 +1,5 @@
<template>
- <div class="app">
+ <div id="app">
<ModalManager />
<ContextMenuManager />
<NuxtPage />
@@ -36,7 +36,7 @@ watch(
</script>
<style lang="scss">
-.app {
+#app {
height: 100vh;
overflow: auto;
display: flex;
diff --git a/frontend/app/components/Node/TOC/TOC.vue b/frontend/app/components/Node/TOC/TOC.vue
index 0e6ab6ca..29fc4ae2 100644
--- a/frontend/app/components/Node/TOC/TOC.vue
+++ b/frontend/app/components/Node/TOC/TOC.vue
@@ -81,11 +81,18 @@ const headers_tree = computed(() => buildTree(getHeaders(headers.value)));
const marker = ref<HTMLElement>();
-onMounted(() => document.addEventListener('scroll', updateActiveHeader, { passive: true }));
-onBeforeUnmount(() => document.removeEventListener('scroll', updateActiveHeader));
+const appElement = ref<HTMLElement | null>(null);
+
+onMounted(() => {
+ appElement.value = document.getElementById('app');
+ appElement.value?.addEventListener('scroll', updateActiveHeader, { passive: true });
+});
+onBeforeUnmount(() => appElement.value?.removeEventListener('scroll', updateActiveHeader));
function updateActiveHeader() {
- const scrollPosition = window.scrollY + window.innerHeight / 4; // quart de la hauteur écran
+ if (!appElement.value) return;
+ const scrollTop = appElement.value.scrollTop;
+ const scrollPosition = scrollTop + window.innerHeight / 4;
let activeHeader: HTMLElement | null = null;
for (const header of headers.value) {