prevent escape from undoing text change
This commit is contained in:
parent
7028877699
commit
1c753b73ac
3 changed files with 19 additions and 4 deletions
|
@ -84,7 +84,12 @@ export class StickyUtil extends TDShapeUtil<T, E> {
|
|||
|
||||
const handleKeyDown = React.useCallback(
|
||||
(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
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()
|
||||
|
|
|
@ -131,7 +131,12 @@ export class TextUtil extends TDShapeUtil<T, E> {
|
|||
|
||||
const handleKeyDown = React.useCallback(
|
||||
(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
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()
|
||||
|
|
|
@ -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<HTMLTextAreaElement>) => {
|
||||
if (e.key === 'Escape') return
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
onBlur?.()
|
||||
return
|
||||
}
|
||||
|
||||
if (e.key === 'Tab' && text.length === 0) {
|
||||
e.preventDefault()
|
||||
|
|
Loading…
Reference in a new issue