diff --git a/packages/tldraw/src/state/shapes/StickyUtil/StickyUtil.tsx b/packages/tldraw/src/state/shapes/StickyUtil/StickyUtil.tsx index a5b082858..754bae57c 100644 --- a/packages/tldraw/src/state/shapes/StickyUtil/StickyUtil.tsx +++ b/packages/tldraw/src/state/shapes/StickyUtil/StickyUtil.tsx @@ -84,7 +84,12 @@ export class StickyUtil extends TDShapeUtil { const handleKeyDown = React.useCallback( (e: React.KeyboardEvent) => { - if (e.key === 'Escape') return + if (e.key === 'Escape') { + e.preventDefault() + e.stopPropagation() + onShapeBlur?.() + return + } if (e.key === 'Tab' && shape.text.length === 0) { e.preventDefault() diff --git a/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx b/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx index 2225b1b2e..f4f7016b8 100644 --- a/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx +++ b/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx @@ -131,7 +131,12 @@ export class TextUtil extends TDShapeUtil { const handleKeyDown = React.useCallback( (e: React.KeyboardEvent) => { - if (e.key === 'Escape') return + if (e.key === 'Escape') { + e.preventDefault() + e.stopPropagation() + onShapeBlur?.() + return + } if (e.key === 'Tab' && shape.text.length === 0) { e.preventDefault() diff --git a/packages/tldraw/src/state/shapes/shared/TextLabel.tsx b/packages/tldraw/src/state/shapes/shared/TextLabel.tsx index 3622166ff..55ac63833 100644 --- a/packages/tldraw/src/state/shapes/shared/TextLabel.tsx +++ b/packages/tldraw/src/state/shapes/shared/TextLabel.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import { stopPropagation } from '~components/stopPropagation' -import { GHOSTED_OPACITY, LETTER_SPACING } from '~constants' +import { GHOSTED_OPACITY, LETTER_SPACING } from '~constants' import { TLDR } from '~state/TLDR' import { styled } from '~styles' import { getTextLabelSize } from './getTextSize' @@ -40,7 +40,12 @@ export const TextLabel = React.memo(function TextLabel({ ) const handleKeyDown = React.useCallback( (e: React.KeyboardEvent) => { - if (e.key === 'Escape') return + if (e.key === 'Escape') { + e.preventDefault() + e.stopPropagation() + onBlur?.() + return + } if (e.key === 'Tab' && text.length === 0) { e.preventDefault()