Skip to content

Conversation

@shaohuzhang1
Copy link
Contributor

fix: Workflow adding nodes sometimes fails to connect correctly to anchor points

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Oct 17, 2025

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.

Details

Instructions 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.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Oct 17, 2025

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

targetAnchorId: nodeModel.id + '_left',
})
closeNodeMenu()
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 code snippet is for a JavaScript/TypeScript function clickNodes that sets up an event handler to handle clicks on nodes within a graph or diagram. Specifically, it appears to be related to connecting two nodes with an edge.

Here are some potential issues and suggestions:

  1. Duplicate Target Node IDs:

    targetNodeId: nodeModel.id + '_left';

    If nodeModel.id ends with _left, adding .value?._id from the anchorData before this line would prevent errors if anchorData might not exist. However, without additional context, this could lead to unexpected behavior if there's no default value for anchorData.

  2. Event Handling:
    The code doesn’t specifically mention how the clickNodes function was triggered (e.g., via an event listener). Ensure that this function is correctly hooked up in your application to manage clicking events on nodes.

  3. Function Body:
    There is only one action (createConnection) being performed inside the clickNodes function. This should either call multiple functions sequentially or group them appropriately. Consider whether there’s redundancy in actions being repeated multiple times.

  4. Node Model ID Concatenation with "_left":
    It's important to verify that concatenating strings like ${props.nodeModel.id}_left aligns with the data format expected throughout your application. Ensure consistency in naming conventions and data manipulation logic.

Suggested improvement ideas:

  • Use type checking to ensure all required properties (sourceNodeId, targetNodeId) exist and have valid values.
  • Add comments or documentation explaining the purpose and flow of the clickNodes function.
  • Simplify complex expressions by breaking them into smaller, more readable parts. For example,
    const sourceAnchor = anchorData && anchorData.value ? { id: anchorData.value.id, } : null;
    createConnection({
      sourceNodeId: props.nodeModel.id,
      sourceAnchorId: sourceAnchor && sourceAnchor.id,
      targetNodeId: nodeModel.id,
      targetAnchorId: nodeModel.id + '_left',
    });

These checks and improvements can help ensure the function behaves as intended across different contexts and provides clearer code structure.

@shaohuzhang1 shaohuzhang1 merged commit 5189816 into v2 Oct 17, 2025
4 of 5 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@fix_workflow branch October 17, 2025 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants