From 14c112cec50ada65eef1c057a5205f82d18b084d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Mon, 9 Mar 2026 16:31:27 +0800 Subject: [PATCH] Add bounds checks in highlightClickedPath to prevent undefined access Co-Authored-By: Claude Opus 4.6 --- src/stores/mapPathStore.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/stores/mapPathStore.ts b/src/stores/mapPathStore.ts index 8ff51a0..6c2af8c 100644 --- a/src/stores/mapPathStore.ts +++ b/src/stores/mapPathStore.ts @@ -224,10 +224,13 @@ export const useMapPathStore = defineStore('mapPathStore', { return false; // Return false when the current node does not match }, highlightClickedPath(clickedActiveTraceIndex: number, clickedPathListIndex: number) { - this.insightWithPath[INSIGHTS_FIELDS_AND_LABELS[clickedActiveTraceIndex][0]][clickedPathListIndex].edges.forEach(edgeToHighlight => { + const key = INSIGHTS_FIELDS_AND_LABELS[clickedActiveTraceIndex]?.[0]; + const path = this.insightWithPath?.[key]?.[clickedPathListIndex]; + if (!path) return; + path.edges.forEach(edgeToHighlight => { edgeToHighlight.addClass('highlight-edge'); }); - this.insightWithPath[INSIGHTS_FIELDS_AND_LABELS[clickedActiveTraceIndex][0]][clickedPathListIndex].nodes.forEach(nodeToHighlight => { + path.nodes.forEach(nodeToHighlight => { nodeToHighlight.data('nodeImageUrl', ImgCapsulesGlow[nodeToHighlight.data('level')]); }); },