Add bounds checks in highlightClickedPath to prevent undefined access

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 16:31:27 +08:00
parent a6d32672bc
commit 14c112cec5

View File

@@ -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')]);
});
},