Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@
<template
v-for="(cLoop, cIndex) in Object.values(
data.loop_node_data?.[currentLoopNode] || [],
)"
).sort((x: any, y: any) => (x.index || 0) - (y.index || 0))"
:key="cIndex"
>
<ExecutionDetailCard :data="cLoop"></ExecutionDetailCard>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided line introduces a bug in the code. In JavaScript ES6 Object.values, when used to iterate over object properties, it returns an array of values that correspond to those properties without keys. The subsequent .sort() operation expects two parameters for comparison, but the current implementation only references one ((x: any)). To sort objects by a specific property like "index", you need to access that property within the sorting function.

Here is the corrected version of the line:

v-for="(cLoop, cIndex) in Object.values(data.loop_node_data?.[currentLoopNode] || []).sort((x: any, y: any) => (x.index || 0) - (y.index || 0))"

By adding another reference to (y.index || 0) before subtracting from each other, the function now correctly sorts the objects based on their index attribute, assuming all elements have at least an index field or default to zero if missing.

Expand Down
Loading