Improve text bug

This commit is contained in:
Steve Ruiz 2021-06-30 23:44:25 +01:00
parent 7da573ffdb
commit b426c40bd8
3 changed files with 13 additions and 6 deletions

View file

@ -85,7 +85,7 @@ export default function ContextMenu({
const hasGroupSelected = useSelector((s) => const hasGroupSelected = useSelector((s) =>
selectedShapeIds.some( selectedShapeIds.some(
(id) => tld.getShape(s.data, id).type === ShapeType.Group (id) => tld.getShape(s.data, id)?.type === ShapeType.Group
) )
) )

View file

@ -132,6 +132,7 @@ const ForeignObjectHover = memo(function ForeignObjectHover({
}) { }) {
const size = useSelector((s) => { const size = useSelector((s) => {
const shape = tld.getPage(s.data).shapes[id] const shape = tld.getPage(s.data).shapes[id]
if (shape === undefined) return [0, 0]
const bounds = getShapeUtils(shape).getBounds(shape) const bounds = getShapeUtils(shape).getBounds(shape)
return [bounds.width, bounds.height] return [bounds.width, bounds.height]
@ -159,8 +160,6 @@ const ForeignObjectRender = memo(function ForeignObjectRender({
const isEditing = useSelector((s) => s.data.editingId === id) const isEditing = useSelector((s) => s.data.editingId === id)
const shapeUtils = getShapeUtils(shape)
useEffect(() => { useEffect(() => {
if (isEditing) { if (isEditing) {
setTimeout(() => { setTimeout(() => {
@ -171,7 +170,9 @@ const ForeignObjectRender = memo(function ForeignObjectRender({
} }
}, [isEditing]) }, [isEditing])
return shapeUtils.render(shape, { isEditing, ref: rFocusable }) if (shape === undefined) return null
return getShapeUtils(shape).render(shape, { isEditing, ref: rFocusable })
}) })
const StyledShape = styled('path', { const StyledShape = styled('path', {

View file

@ -625,8 +625,14 @@ const state = createState({
onExit: ['completeSession', 'clearEditingId'], onExit: ['completeSession', 'clearEditingId'],
on: { on: {
EDITED_SHAPE: { do: 'updateEditSession' }, EDITED_SHAPE: { do: 'updateEditSession' },
BLURRED_EDITING_SHAPE: [
BLURRED_EDITING_SHAPE: { to: 'selecting' }, {
get: 'editingShape',
if: 'shouldDeleteShape',
do: ['cancelSession', 'deleteSelection'],
},
{ to: 'selecting' },
],
CANCELLED: [ CANCELLED: [
{ {
get: 'editingShape', get: 'editingShape',