From 6f57c767f46e3c9af0947bc9b505befd0d097f90 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Mon, 15 Dec 2025 20:04:55 -0500 Subject: [PATCH] fix: prevent ValidationError by not setting undefined values in shape.meta MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When unpinning a shape, the previous code set pinnedAtZoom, originalX, and originalY to undefined in shape.meta. This caused a ValidationError because tldraw requires JSON serializable values (undefined is not valid JSON). Fixed by using object destructuring to exclude these properties from meta instead of setting them to undefined. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/hooks/usePinnedToView.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/hooks/usePinnedToView.ts b/src/hooks/usePinnedToView.ts index 5451753..46e283e 100644 --- a/src/hooks/usePinnedToView.ts +++ b/src/hooks/usePinnedToView.ts @@ -175,17 +175,14 @@ export function usePinnedToView( } else { // Animation complete - clear pinned meta data try { + // Create new meta without pinned properties (don't use undefined) + const { pinnedAtZoom, originalX, originalY, ...cleanMeta } = (currentShape.meta || {}) as any editor.updateShape({ id: shapeId as TLShapeId, type: currentShape.type, x: targetX, y: targetY, - meta: { - ...currentShape.meta, - pinnedAtZoom: undefined, - originalX: undefined, - originalY: undefined, - }, + meta: cleanMeta, }) } catch (error) { console.error('Error setting final position:', error) @@ -198,17 +195,14 @@ export function usePinnedToView( } else { // Distance is too small, just set directly and clear meta try { + // Create new meta without pinned properties (don't use undefined) + const { pinnedAtZoom, originalX, originalY, ...cleanMeta } = (currentShape.meta || {}) as any editor.updateShape({ id: shapeId as TLShapeId, type: currentShape.type, x: targetX, y: targetY, - meta: { - ...currentShape.meta, - pinnedAtZoom: undefined, - originalX: undefined, - originalY: undefined, - }, + meta: cleanMeta, }) } catch (error) { console.error('Error restoring original coordinates:', error)