From 8039016416393f81a0ae39b399df26508dff5502 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Thu, 10 Mar 2022 19:39:21 +0000 Subject: [PATCH] [fix] Only delete bindings if they were attached to a deleted group shape (#617) * Only delete bindings if they were attached to a deleted group shape * Update TransformSingleSession.ts --- packages/tldraw/src/state/commands/groupShapes/groupShapes.ts | 4 +++- .../sessions/TransformSingleSession/TransformSingleSession.ts | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/tldraw/src/state/commands/groupShapes/groupShapes.ts b/packages/tldraw/src/state/commands/groupShapes/groupShapes.ts index efa291c78..3182c4630 100644 --- a/packages/tldraw/src/state/commands/groupShapes/groupShapes.ts +++ b/packages/tldraw/src/state/commands/groupShapes/groupShapes.ts @@ -149,11 +149,13 @@ export function groupShapes( const { bindings } = app + const deletedGroupIdsSet = new Set(deletedGroupIds) + // We also need to delete bindings that reference the deleted shapes bindings.forEach((binding) => { for (const id of [binding.toId, binding.fromId]) { // If the binding references a deleted shape... - if (afterShapes[id] === undefined) { + if (deletedGroupIdsSet.has(id)) { // Delete this binding beforeBindings[binding.id] = binding afterBindings[binding.id] = undefined diff --git a/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.ts b/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.ts index d3c454387..352b057f5 100644 --- a/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.ts +++ b/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.ts @@ -228,8 +228,6 @@ export class TransformSingleSession extends BaseSession { if (initialShape.isLocked) return - console.log('completed', this.app.originPoint, this.app.currentPoint) - if (this.isCreate && Vec.dist(this.app.originPoint, this.app.currentPoint) < 2) { return this.cancel() }