Skip to content

fix: make showConnectionArrows setting properly control arrow visibility#67

Merged
Antamansid merged 3 commits intomainfrom
showConnectionArrows_bug
Apr 21, 2025
Merged

fix: make showConnectionArrows setting properly control arrow visibility#67
Antamansid merged 3 commits intomainfrom
showConnectionArrows_bug

Conversation

@Antamansid
Copy link
Collaborator

@Antamansid Antamansid commented Apr 15, 2025

Fix showConnectionArrows setting

Issue

The showConnectionArrows setting was defined in the configuration but wasn't actually controlling the visibility of connection arrows. Arrows were always being rendered regardless of the setting value.

Root Cause

In the BlockConnection class, the arrow was always being added to the batch renderer in the constructor and updated in the applyShape method, without checking the showConnectionArrows setting.

Additionally, there was an inconsistency between propsChanged and applyShape methods:

  • propsChanged was using nextProps.showConnectionArrows to determine whether to add/remove the arrow
  • applyShape was using this.props.showConnectionArrows which might contain outdated values

Changes

  1. Added an arrowAddedToBatch flag to track whether the arrow is currently in the batch renderer
  2. Centralized all arrow visibility logic in the applyShape method
  3. Modified applyShape to accept an optional props parameter, allowing it to work with the most current props
  4. Updated propsChanged to pass the new props to applyShape
  5. Updated unmount to only delete the arrow if it's actually in the batch
  6. Added comprehensive JSDoc comments to explain the arrow rendering logic and potential pitfalls

Testing

Verified that:

  • When showConnectionArrows is true, arrows are displayed in the middle of connections
  • When showConnectionArrows is false, arrows are not displayed
  • When the setting is changed at runtime, arrows appear/disappear accordingly

@Antamansid Antamansid marked this pull request as ready for review April 15, 2025 09:53
@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@draedful draedful self-assigned this Apr 15, 2025
@Antamansid Antamansid requested a review from draedful April 15, 2025 11:50
@Antamansid Antamansid merged commit 8139e37 into main Apr 21, 2025
4 checks passed
@Antamansid Antamansid deleted the showConnectionArrows_bug branch April 21, 2025 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants