From 8f062f21d8a7ee51b4ec95f94887d40242ce1682 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 22 Nov 2025 14:46:01 +0100 Subject: [PATCH] fix: add null checks and type assertion in ProjectsNavigation.vue --- frontend/src/components/home/ProjectsNavigation.vue | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/home/ProjectsNavigation.vue b/frontend/src/components/home/ProjectsNavigation.vue index 932168275..347f2f13f 100644 --- a/frontend/src/components/home/ProjectsNavigation.vue +++ b/frontend/src/components/home/ProjectsNavigation.vue @@ -82,10 +82,15 @@ async function saveProjectPosition(e: SortableEvent) { // To work around that we're explicitly checking that case here and decrease the index. const newIndex = e.newIndex === projectsActive.length ? e.newIndex - 1 : e.newIndex - const projectId = parseInt(e.item.dataset.projectId) - const project = projectStore.projects[projectId] + const projectIdStr = e.item.dataset.projectId + if (!projectIdStr) return - const parentProjectId = e.to.parentNode.dataset.projectId ? parseInt(e.to.parentNode.dataset.projectId) : 0 + const projectId = parseInt(projectIdStr) + const project = projectStore.projects[projectId] + if (!project) return + + const parentNode = e.to.parentNode as HTMLElement | null + const parentProjectId = parentNode?.dataset?.projectId ? parseInt(parentNode.dataset.projectId) : 0 const projectBefore = projectsActive[newIndex - 1] ?? null const projectAfter = projectsActive[newIndex + 1] ?? null projectUpdating.value[project.id] = true @@ -101,7 +106,7 @@ async function saveProjectPosition(e: SortableEvent) { ...project, position, parentProjectId, - }) + } as IProject) emit('update:modelValue', availableProjects.value) } finally { projectUpdating.value[project.id] = false