diff --git a/tldraw/packages/core/src/lib/tools/TLTextTool/states/CreatingState.tsx b/tldraw/packages/core/src/lib/tools/TLTextTool/states/CreatingState.tsx index 3ea6e0866..04d83b652 100644 --- a/tldraw/packages/core/src/lib/tools/TLTextTool/states/CreatingState.tsx +++ b/tldraw/packages/core/src/lib/tools/TLTextTool/states/CreatingState.tsx @@ -1,5 +1,6 @@ import type { TLTextTool } from '../TLTextTool' import Vec from '@tldraw/vec' +import { GRID_SIZE } from '@tldraw/core' import type { TLBounds } from '@tldraw/intersect' import { transaction } from 'mobx' import { type TLEventMap, TLCursor, TLTargetType } from '../../../../types' @@ -43,8 +44,10 @@ export class CreatingState< this.creatingShape.setScaleLevel(this.app.settings.scaleLevel) transaction(() => { this.app.currentPage.addShapes(shape as unknown as S) + const point = this.app.settings.snapToGrid ? Vec.snap([...originPoint], GRID_SIZE) : originPoint const { bounds } = shape - shape.update({ point: Vec.sub(originPoint, [bounds.width / 2, bounds.height / 2]) }) + shape.update({ + point: Vec.sub(point, [bounds.width / 2, bounds.height / 2]) }) this.app.transition('select') this.app.setSelectedShapes([shape as unknown as S]) this.app.currentState.transition('editingShape', {