Conversation
… state (#8167) Previously, any change to any shape would cause all arrows to render. We should be careful with any reactive call to getOnlySelectedShape, because it will call when the selected shape is changing. If we need to react to a change in which shape is selected, we should use getOnlySelectedShapeId. In order to reduce unnecessary re-renders of arrow components, this PR changes a call to `getOnlySelectedShape()?.id` to `getOnlySelectedShapeId`. To avoid an extra render when editing shape changes, it also wraps `shouldDisplayHandles` and `isEditing` checks in `useValue` hooks for finer-grained reactivity. It also refactors `getArrowLabelPosition` to accept `isEditing` as a parameter rather than computing it internally, avoiding redundant reactive lookups. ### Change type - [x] `improvement` ### Test plan 1. Create arrows between shapes 2. Select an arrow — handles should display correctly 3. Double-click an arrow label to edit — label positioning should work as before 4. Deselect and verify handles disappear - [ ] Unit tests - [ ] End to end tests ### Release notes - Improve arrow component rendering performance with finer-grained reactivity <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches arrow rendering reactivity (selection/editing state and label positioning), so regressions could show up as missing handles or mispositioned labels, but the changes are localized to UI/perf code. > > **Overview** > Reduces unnecessary arrow re-renders by switching arrow component state derivations to fine-grained `useValue` subscriptions (e.g. `shouldDisplayHandles`, selection, and editing state) and by preferring `getOnlySelectedShapeId()` over `getOnlySelectedShape()` where only the id is needed. > > Refactors `getArrowLabelPosition` to accept an explicit `isEditing` flag and updates all call sites (geometry, component render, and SVG export) to avoid redundant reactive lookups when computing label bounds. Also updates touch-end handling in `useCanvasEvents` to use `editor.getEditingShapeId()`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit e04558e. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )