Skip to content

[pull] main from tldraw:main#432

Merged
pull[bot] merged 1 commit intocode:mainfrom
tldraw:main
Mar 6, 2026
Merged

[pull] main from tldraw:main#432
pull[bot] merged 1 commit intocode:mainfrom
tldraw:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Mar 6, 2026

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 : )

… 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 -->
@pull pull Bot locked and limited conversation to collaborators Mar 6, 2026
@pull pull Bot added the ⤵️ pull label Mar 6, 2026
@pull pull Bot merged commit 6f8851f into code:main Mar 6, 2026
@pull pull Bot had a problem deploying to bemo-canary March 6, 2026 03:13 Failure
@pull pull Bot had a problem deploying to deploy-production March 6, 2026 03:13 Failure
@pull pull Bot had a problem deploying to vsce publish March 6, 2026 03:13 Failure
@pull pull Bot had a problem deploying to bemo-canary March 6, 2026 03:13 Failure
@pull pull Bot had a problem deploying to deploy-staging March 6, 2026 03:13 Failure
@pull pull Bot had a problem deploying to deploy-staging March 6, 2026 03:13 Error
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant