Fixes text on mobile (iOS)
This commit is contained in:
parent
eccf5f6307
commit
5f71f5c38b
4 changed files with 21 additions and 5 deletions
|
@ -27,7 +27,11 @@ function Shape({ id, isSelecting, parentPoint }: ShapeProps) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isEditing) {
|
if (isEditing) {
|
||||||
setTimeout(() => rFocusable.current?.focus(), 0)
|
setTimeout(() => {
|
||||||
|
const elm = rFocusable.current
|
||||||
|
if (!elm) return
|
||||||
|
elm.focus()
|
||||||
|
}, 0)
|
||||||
}
|
}
|
||||||
}, [isEditing])
|
}, [isEditing])
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { MutableRefObject, useCallback, useRef } from 'react'
|
import React, { MutableRefObject, useCallback, useRef } from 'react'
|
||||||
import state from 'state'
|
import state from 'state'
|
||||||
import inputs from 'state/inputs'
|
import inputs from 'state/inputs'
|
||||||
|
|
||||||
|
@ -76,11 +76,21 @@ export default function useShapeEvents(
|
||||||
[id]
|
[id]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const handleTouchStart = useCallback((e: React.TouchEvent) => {
|
||||||
|
e.preventDefault()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handleTouchEnd = useCallback((e: React.TouchEvent) => {
|
||||||
|
e.preventDefault()
|
||||||
|
}, [])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
onPointerDown: handlePointerDown,
|
onPointerDown: handlePointerDown,
|
||||||
onPointerUp: handlePointerUp,
|
onPointerUp: handlePointerUp,
|
||||||
onPointerEnter: handlePointerEnter,
|
onPointerEnter: handlePointerEnter,
|
||||||
onPointerMove: handlePointerMove,
|
onPointerMove: handlePointerMove,
|
||||||
onPointerLeave: handlePointerLeave,
|
onPointerLeave: handlePointerLeave,
|
||||||
|
onTouchStart: handleTouchStart,
|
||||||
|
onTouchEnd: handleTouchEnd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { uniqueId } from 'utils/utils'
|
import { uniqueId, isMobile } from 'utils/utils'
|
||||||
import vec from 'utils/vec'
|
import vec from 'utils/vec'
|
||||||
import { TextShape, ShapeType, FontSize, SizeStyle } from 'types'
|
import { TextShape, ShapeType, FontSize, SizeStyle } from 'types'
|
||||||
import { registerShapeUtils } from './index'
|
import { registerShapeUtils } from './index'
|
||||||
|
@ -118,6 +118,7 @@ const text = registerShapeUtils<TextShape>({
|
||||||
autoComplete="false"
|
autoComplete="false"
|
||||||
autoCapitalize="false"
|
autoCapitalize="false"
|
||||||
autoCorrect="false"
|
autoCorrect="false"
|
||||||
|
autoFocus={isMobile() ? true : false}
|
||||||
onFocus={handleFocus}
|
onFocus={handleFocus}
|
||||||
onBlur={handleBlur}
|
onBlur={handleBlur}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
|
@ -236,7 +237,6 @@ const StyledText = styled('div', {
|
||||||
pointerEvents: 'none',
|
pointerEvents: 'none',
|
||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
position: 'relative',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const StyledTextArea = styled('textarea', {
|
const StyledTextArea = styled('textarea', {
|
||||||
|
@ -254,4 +254,6 @@ const StyledTextArea = styled('textarea', {
|
||||||
pointerEvents: 'all',
|
pointerEvents: 'all',
|
||||||
backfaceVisibility: 'hidden',
|
backfaceVisibility: 'hidden',
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
|
userSelect: 'text',
|
||||||
|
WebkitUserSelect: 'text',
|
||||||
})
|
})
|
||||||
|
|
|
@ -114,7 +114,7 @@ const initialData: Data = {
|
||||||
const state = createState({
|
const state = createState({
|
||||||
data: initialData,
|
data: initialData,
|
||||||
on: {
|
on: {
|
||||||
UNMOUNTED: [{ unless: 'isReadOnly', do: 'forceSave' }, { to: 'loading' }],
|
UNMOUNTED: { to: 'loading' },
|
||||||
},
|
},
|
||||||
initial: 'loading',
|
initial: 'loading',
|
||||||
states: {
|
states: {
|
||||||
|
|
Loading…
Reference in a new issue