feat(editor): pass shapes to ShapeUtil.canBind()#7821
Merged
MitjaBezensek merged 2 commits intomainfrom Feb 11, 2026
Merged
Conversation
canBind now receives fromShape/toShape as TLShape | { type } unions
instead of just type strings.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
1 task
mimecuvalo
reviewed
Feb 5, 2026
| /** The type of shape referenced by the `toId` of the binding. */ | ||
| toShapeType: TLShape['type'] | ||
| /** The shape referenced by the `fromId` of the binding, or a `{ type }` stub if unavailable. */ | ||
| fromShape: TLShape | { type: TLShape['type'] } |
Member
There was a problem hiding this comment.
can we avoid making this a breaking change? we're getting feedback that we're causing a lot of downstream thrash for customers.
possible to make the previous options deprecated, for now? 🙏
Contributor
Author
There was a problem hiding this comment.
Good shout! Done.
mimecuvalo
approved these changes
Feb 9, 2026
Member
mimecuvalo
left a comment
There was a problem hiding this comment.
pre-approving modulo last comment
| override canBind({ toShape }: TLShapeUtilCanBindOpts<TLArrowShape>): boolean { | ||
| // bindings can go from arrows to shapes, but not from shapes to arrows | ||
| return toShapeType !== 'arrow' | ||
| return toShape.type !== 'arrow' |
Member
There was a problem hiding this comment.
should this be: (toShape.type ?? toShapeType)
Contributor
Author
There was a problem hiding this comment.
No, don't think we need that. We pass the same thing in both of them.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 11, 2026
Closes #7748 `ShapeUtil.canBind()` previously only received shape type strings via `fromShapeType`/`toShapeType`, making it impossible to make binding decisions based on shape props. This PR replaces those with `fromShape`/`toShape` as `TLShape | { type }` unions — matching the pattern already used by `Editor.canBindShapes()`. When the full shape exists, it's passed directly. When it doesn't (e.g. during arrow creation before the arrow is committed to the store), a `{ type }` stub is passed instead. Consumers can use `'id' in shape` to narrow to `TLShape` when they need prop access. ### Change type - [x] `api` ### Test plan 1. Create arrows and verify they still bind to shapes correctly 2. Verify group shapes still reject bindings 3. Check pin-bindings, layout-bindings, and sticker-bindings examples still work - [ ] Unit tests - [ ] End to end tests ### API changes - Breaking! Removed `fromShapeType` and `toShapeType` from `TLShapeUtilCanBindOpts` - Added `fromShape: TLShape | { type: TLShape['type'] }` to `TLShapeUtilCanBindOpts` - Added `toShape: TLShape | { type: TLShape['type'] }` to `TLShapeUtilCanBindOpts` ### Release notes - Pass full shapes (when possible) to `ShapeUtil.canBind()` so binding decisions can be based on shape props, not just types. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches a core editor API used by all binding checks and introduces a signature/typing change that may break downstream `canBind` implementations or edge cases where only type stubs are available. > > **Overview** > `ShapeUtil.canBind()` now receives `fromShape`/`toShape` (either full `TLShape` objects or `{ type }` stubs) via an expanded `TLShapeUtilCanBindOpts`, enabling binding decisions based on actual shape data when available. > > `Editor.canBindShapes()` constructs and passes these new fields while keeping `fromShapeType`/`toShapeType` as *deprecated* compatibility fields, and example utils (layout bindings, pin bindings) plus `ArrowShapeUtil` are updated to use `fromShape.type`/`toShape.type`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit b971312. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Closed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #7748
ShapeUtil.canBind()previously only received shape type strings viafromShapeType/toShapeType, making it impossible to make binding decisions based on shape props. This PR replaces those withfromShape/toShapeasTLShape | { type }unions — matching the pattern already used byEditor.canBindShapes().When the full shape exists, it's passed directly. When it doesn't (e.g. during arrow creation before the arrow is committed to the store), a
{ type }stub is passed instead. Consumers can use'id' in shapeto narrow toTLShapewhen they need prop access.Change type
apiTest plan
API changes
fromShapeTypeandtoShapeTypefromTLShapeUtilCanBindOptsfromShape: TLShape | { type: TLShape['type'] }toTLShapeUtilCanBindOptstoShape: TLShape | { type: TLShape['type'] }toTLShapeUtilCanBindOptsRelease notes
ShapeUtil.canBind()so binding decisions can be based on shape props, not just types.Note
Medium Risk
Touches a core editor API used by all binding checks and introduces a signature/typing change that may break downstream
canBindimplementations or edge cases where only type stubs are available.Overview
ShapeUtil.canBind()now receivesfromShape/toShape(either fullTLShapeobjects or{ type }stubs) via an expandedTLShapeUtilCanBindOpts, enabling binding decisions based on actual shape data when available.Editor.canBindShapes()constructs and passes these new fields while keepingfromShapeType/toShapeTypeas deprecated compatibility fields, and example utils (layout bindings, pin bindings) plusArrowShapeUtilare updated to usefromShape.type/toShape.type.Written by Cursor Bugbot for commit b971312. This will update automatically on new commits. Configure here.