diff --git a/frontend/src/components/gantt/primitives/GanttChartPrimitive.vue b/frontend/src/components/gantt/primitives/GanttChartPrimitive.vue index 514648361..e5454ba0a 100644 --- a/frontend/src/components/gantt/primitives/GanttChartPrimitive.vue +++ b/frontend/src/components/gantt/primitives/GanttChartPrimitive.vue @@ -35,9 +35,12 @@ const focusedCellIndex = ref(null) const focusedRow = computed(() => focusedRowIndex.value === null ? null : props.rows[focusedRowIndex.value]) -const cellsCount = computed(() => props.rows.length - ? props.cellsByRow[props.rows[0]].length - : 0) +const cellsCount = computed(() => { + const firstRow = props.rows[0] + return firstRow !== undefined && props.cellsByRow[firstRow] + ? props.cellsByRow[firstRow].length + : 0 +}) onClickOutside(chartRef, () => { focusedRowIndex.value = null @@ -63,7 +66,7 @@ function initializeFocus() { if (focusedRowIndex.value === null && props.rows.length > 0) { focusedRowIndex.value = 0 focusedCellIndex.value = 0 - emit('update:focused', { row: focusedRow.value, cell: focusedCellIndex.value }) + emit('update:focused', { row: focusedRow.value ?? null, cell: focusedCellIndex.value }) } } @@ -72,7 +75,7 @@ function setFocus(rowId: string, cellIndex: number = 0) { if (rowIndex !== -1) { focusedRowIndex.value = rowIndex focusedCellIndex.value = Math.max(0, Math.min(cellIndex, cellsCount.value - 1)) - emit('update:focused', { row: focusedRow.value, cell: focusedCellIndex.value }) + emit('update:focused', { row: focusedRow.value ?? null, cell: focusedCellIndex.value }) } }