fix: In the execution details, the display order of the child nodes of the loop body is incorrect#4461
Conversation
…f the loop body is incorrect
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
| ).sort((x: any, y: any) => (x.index || 0) - (y.index || 0))" | ||
| :key="cIndex" | ||
| > | ||
| <ExecutionDetailCard :data="cLoop"></ExecutionDetailCard> |
There was a problem hiding this comment.
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.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
fix: In the execution details, the display order of the child nodes of the loop body is incorrect